From 324077fb48ec38f9337f0875f2b21111929466b5 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 3 Aug 2020 14:45:03 +0100 Subject: [PATCH] swift: fix update multipart object removing all of its own parts After uploading a multipart object, rclone deletes any unused parts. Probably as part of the listing unification, the detection of the parts beloning to the current upload was failing and calling Update was deleting the parts for the current object. This change fixes the detection and deletes all the old parts but none of the new ones now. Fixes #4075 --- backend/swift/swift.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/swift/swift.go b/backend/swift/swift.go index 761b8f9c8..c44b7feec 100644 --- a/backend/swift/swift.go +++ b/backend/swift/swift.go @@ -1115,13 +1115,18 @@ func min(x, y int64) int64 { // // if except is passed in then segments with that prefix won't be deleted func (o *Object) removeSegments(except string) error { - segmentsContainer, prefix, err := o.getSegmentsDlo() - err = o.fs.listContainerRoot(segmentsContainer, prefix, "", false, true, true, func(remote string, object *swift.Object, isDirectory bool) error { + segmentsContainer, _, err := o.getSegmentsDlo() + if err != nil { + return err + } + except = path.Join(o.remote, except) + // fs.Debugf(o, "segmentsContainer %q prefix %q", segmentsContainer, prefix) + err = o.fs.listContainerRoot(segmentsContainer, o.remote, "", false, true, true, func(remote string, object *swift.Object, isDirectory bool) error { if isDirectory { return nil } if except != "" && strings.HasPrefix(remote, except) { - // fs.Debugf(o, "Ignoring current segment file %q in container %q", segmentsRoot+remote, segmentsContainer) + // fs.Debugf(o, "Ignoring current segment file %q in container %q", remote, segmentsContainer) return nil } fs.Debugf(o, "Removing segment file %q in container %q", remote, segmentsContainer)