From c03266f669b347bbf0818d1b0b1e00fbe591080f Mon Sep 17 00:00:00 2001 From: Benjamin Ritter Date: Fri, 23 Feb 2024 18:08:29 +0100 Subject: [PATCH] fix: Use correct path normalization within Storage Zone previously the path parsed out of list responses did not contain the whole path. This commit allows juicefs delete, sync etc. to work properly --- pkg/object/bunny.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/object/bunny.go b/pkg/object/bunny.go index 06696f726eb57..1d950c9f6e70d 100644 --- a/pkg/object/bunny.go +++ b/pkg/object/bunny.go @@ -118,9 +118,8 @@ func (b *bunnyClient) walkObjects(prefix string, marker string, out chan<- Objec return } objectsToProcess = append(objectsToProcess, objects...) - } else { - out <- parseObjectMetadata(o) } + out <- parseObjectMetadata(o) } } } @@ -129,6 +128,9 @@ func (b *bunnyClient) walkObjects(prefix string, marker string, out chan<- Objec // The Object Path returned by the Bunny API contains the Storage Zone Name, which this function removes func normalizedObjectNameWithinZone(o bunnystorage.Object) string { normalizedPath := path.Join(o.Path, o.ObjectName) + if o.IsDirectory { + normalizedPath = normalizedPath+"/" // Append a trailing slash to allow deletion of directories + } return strings.TrimPrefix(normalizedPath, "/"+o.StorageZoneName+"/") } @@ -136,7 +138,7 @@ func normalizedObjectNameWithinZone(o bunnystorage.Object) string { func parseObjectMetadata(object bunnystorage.Object) Object { lastChanged, _ := time.Parse("2006-01-02T15:04:05", object.LastChanged) return &obj{ - object.ObjectName, + normalizedObjectNameWithinZone(object), int64(object.Length), lastChanged, object.IsDirectory,