forked from TrueCloudLab/frostfs-s3-gw
[#503] Handle leading slash in names
Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
parent
59570ac075
commit
64931c77f4
1 changed files with 8 additions and 2 deletions
|
@ -74,7 +74,7 @@ const (
|
||||||
settingsFileName = "bucket-settings"
|
settingsFileName = "bucket-settings"
|
||||||
notifConfFileName = "bucket-notifications"
|
notifConfFileName = "bucket-notifications"
|
||||||
corsFilename = "bucket-cors"
|
corsFilename = "bucket-cors"
|
||||||
emptyFileName = "<empty>" // to handle trailing slash in name
|
emptyFileName = "<empty>" // to handle trailing and leading slash in name
|
||||||
bucketTaggingFilename = "bucket-tagging"
|
bucketTaggingFilename = "bucket-tagging"
|
||||||
|
|
||||||
// versionTree -- ID of a tree with object versions.
|
// versionTree -- ID of a tree with object versions.
|
||||||
|
@ -527,9 +527,12 @@ func (c *TreeClient) GetLatestVersion(ctx context.Context, cnrID *cid.ID, object
|
||||||
return c.getLatestVersion(ctx, cnrID, versionTree, path, meta)
|
return c.getLatestVersion(ctx, cnrID, versionTree, path, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pathFromName splits name by '/' and add an empty marker if name has trailing slash.
|
// pathFromName splits name by '/' and add an empty marker if name has trailing or leading slash.
|
||||||
func pathFromName(objectName string) []string {
|
func pathFromName(objectName string) []string {
|
||||||
path := strings.Split(objectName, separator)
|
path := strings.Split(objectName, separator)
|
||||||
|
if path[0] == "" {
|
||||||
|
path[0] = emptyFileName
|
||||||
|
}
|
||||||
if path[len(path)-1] == "" {
|
if path[len(path)-1] == "" {
|
||||||
path[len(path)-1] = emptyFileName
|
path[len(path)-1] = emptyFileName
|
||||||
}
|
}
|
||||||
|
@ -560,6 +563,9 @@ func (c *TreeClient) GetLatestVersionsByPrefix(ctx context.Context, cnrID *cid.I
|
||||||
func (c *TreeClient) determinePrefixNode(ctx context.Context, cnrID *cid.ID, treeID, prefix string) (uint64, string, error) {
|
func (c *TreeClient) determinePrefixNode(ctx context.Context, cnrID *cid.ID, treeID, prefix string) (uint64, string, error) {
|
||||||
var rootID uint64
|
var rootID uint64
|
||||||
path := strings.Split(prefix, separator)
|
path := strings.Split(prefix, separator)
|
||||||
|
if path[0] == "" {
|
||||||
|
path[0] = emptyFileName
|
||||||
|
}
|
||||||
tailPrefix := path[len(path)-1]
|
tailPrefix := path[len(path)-1]
|
||||||
|
|
||||||
if len(path) > 1 {
|
if len(path) > 1 {
|
||||||
|
|
Loading…
Reference in a new issue