mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	add path prefix to ObjectStorage.Iterator (#23332)
Support to iterator subdirectory in ObjectStorage for ObjectStorage.Iterator method. It's required for https://github.com/go-gitea/gitea/pull/22738 to make artifact files cleanable. --------- Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
		@@ -127,8 +127,12 @@ func (l *LocalStorage) URL(path, name string) (*url.URL, error) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IterateObjects iterates across the objects in the local storage
 | 
			
		||||
func (l *LocalStorage) IterateObjects(fn func(path string, obj Object) error) error {
 | 
			
		||||
	return filepath.WalkDir(l.dir, func(path string, d os.DirEntry, err error) error {
 | 
			
		||||
func (l *LocalStorage) IterateObjects(prefix string, fn func(path string, obj Object) error) error {
 | 
			
		||||
	dir := l.dir
 | 
			
		||||
	if prefix != "" {
 | 
			
		||||
		dir = filepath.Join(l.dir, util.CleanPath(prefix))
 | 
			
		||||
	}
 | 
			
		||||
	return filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user