mirror of
https://github.com/rclone/rclone.git
synced 2024-11-26 10:25:03 +01:00
s3: make purge remove directory markers too
See: https://forum.rclone.org/t/cannot-purge-aws-s3/36169/
This commit is contained in:
parent
de9c4a3611
commit
19e8c8d42a
@ -3468,15 +3468,16 @@ var errEndList = errors.New("end list")
|
|||||||
|
|
||||||
// list options
|
// list options
|
||||||
type listOpt struct {
|
type listOpt struct {
|
||||||
bucket string // bucket to list
|
bucket string // bucket to list
|
||||||
directory string // directory with bucket
|
directory string // directory with bucket
|
||||||
prefix string // prefix to remove from listing
|
prefix string // prefix to remove from listing
|
||||||
addBucket bool // if set, the bucket is added to the start of the remote
|
addBucket bool // if set, the bucket is added to the start of the remote
|
||||||
recurse bool // if set, recurse to read sub directories
|
recurse bool // if set, recurse to read sub directories
|
||||||
withVersions bool // if set, versions are produced
|
withVersions bool // if set, versions are produced
|
||||||
hidden bool // if set, return delete markers as objects with size == isDeleteMarker
|
hidden bool // if set, return delete markers as objects with size == isDeleteMarker
|
||||||
findFile bool // if set, it will look for files called (bucket, directory)
|
findFile bool // if set, it will look for files called (bucket, directory)
|
||||||
versionAt fs.Time // if set only show versions <= this time
|
versionAt fs.Time // if set only show versions <= this time
|
||||||
|
noSkipMarkers bool // if set return dir marker objects
|
||||||
}
|
}
|
||||||
|
|
||||||
// list lists the objects into the function supplied with the opt
|
// list lists the objects into the function supplied with the opt
|
||||||
@ -3621,7 +3622,7 @@ func (f *Fs) list(ctx context.Context, opt listOpt, fn listFn) error {
|
|||||||
remote = bucket.Join(opt.bucket, remote)
|
remote = bucket.Join(opt.bucket, remote)
|
||||||
}
|
}
|
||||||
// is this a directory marker?
|
// is this a directory marker?
|
||||||
if isDirectory && object.Size != nil && *object.Size == 0 {
|
if isDirectory && object.Size != nil && *object.Size == 0 && !opt.noSkipMarkers {
|
||||||
continue // skip directory marker
|
continue // skip directory marker
|
||||||
}
|
}
|
||||||
if versionIDs != nil {
|
if versionIDs != nil {
|
||||||
@ -4568,13 +4569,14 @@ func (f *Fs) purge(ctx context.Context, dir string, oldOnly bool) error {
|
|||||||
delErr <- operations.DeleteFiles(ctx, delChan)
|
delErr <- operations.DeleteFiles(ctx, delChan)
|
||||||
}()
|
}()
|
||||||
checkErr(f.list(ctx, listOpt{
|
checkErr(f.list(ctx, listOpt{
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
directory: directory,
|
directory: directory,
|
||||||
prefix: f.rootDirectory,
|
prefix: f.rootDirectory,
|
||||||
addBucket: f.rootBucket == "",
|
addBucket: f.rootBucket == "",
|
||||||
recurse: true,
|
recurse: true,
|
||||||
withVersions: versioned,
|
withVersions: versioned,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
|
noSkipMarkers: true,
|
||||||
}, func(remote string, object *s3.Object, versionID *string, isDirectory bool) error {
|
}, func(remote string, object *s3.Object, versionID *string, isDirectory bool) error {
|
||||||
if isDirectory {
|
if isDirectory {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user