forked from kevadesu/forgejo
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:
parent
757b4c17e9
commit
cdc9e91750
9 changed files with 67 additions and 15 deletions
|
@ -65,7 +65,7 @@ type ObjectStorage interface {
|
|||
Stat(path string) (os.FileInfo, error)
|
||||
Delete(path string) error
|
||||
URL(path, name string) (*url.URL, error)
|
||||
IterateObjects(func(path string, obj Object) error) error
|
||||
IterateObjects(path string, iterator func(path string, obj Object) error) error
|
||||
}
|
||||
|
||||
// Copy copies a file from source ObjectStorage to dest ObjectStorage
|
||||
|
@ -87,7 +87,7 @@ func Copy(dstStorage ObjectStorage, dstPath string, srcStorage ObjectStorage, sr
|
|||
|
||||
// Clean delete all the objects in this storage
|
||||
func Clean(storage ObjectStorage) error {
|
||||
return storage.IterateObjects(func(path string, obj Object) error {
|
||||
return storage.IterateObjects("", func(path string, obj Object) error {
|
||||
_ = obj.Close()
|
||||
return storage.Delete(path)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue