Skip to content

Commit

Permalink
fix: Use correct path normalization within Storage Zone
Browse files Browse the repository at this point in the history
previously the path parsed out of list responses did not contain the whole path. This commit allows juicefs delete, sync etc. to work properly
  • Loading branch information
l0wl3vel committed Feb 23, 2024
1 parent 0d96a09 commit c03266f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/object/bunny.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -129,14 +128,17 @@ 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+"/")
}

// Parse Bunnystorage API Object to JuiceFS Object
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,
Expand Down

0 comments on commit c03266f

Please sign in to comment.