Subdir mount fails to list blobs (#1099)

* Fix subdir listing to match correct blob names
This commit is contained in:
Vikas Bhansali 2023-04-06 22:56:20 +05:30 коммит произвёл GitHub
Родитель f3a4393f58
Коммит a1f80c4694
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 56 добавлений и 3 удалений

Просмотреть файл

@ -5,6 +5,7 @@
- [#1079](https://github.com/Azure/azure-storage-fuse/issues/1079) Shell returns before child process mounts the container and if user tries to bind the mount it leads to inconsistent state.
- If mount fails in forked child, blobfuse2 will return back with status error code.
- [#1100](https://github.com/Azure/azure-storage-fuse/issues/1100) If content-encoding is set in blob then transport layer compression shall be disabled.
- Subdir mount is not able to list blobs correctly when virtual-directory is turned on.
**Features**
- Added new CLI parameter "--sync-to-flush". Once configured sync() call on file will force upload a file to storage container. As this is file handle based api, if file was not in file-cache it will first download and then upload the file.

Просмотреть файл

@ -498,7 +498,12 @@ func (s *blockBlobTestSuite) TestDeleteSubDirPrefixPath() {
s.az.storage.SetPrefixPath(base)
err := s.az.DeleteDir(internal.DeleteDirOptions{Name: "c1"})
attr, err := s.az.GetAttr(internal.GetAttrOptions{Name: "c1"})
s.assert.Nil(err)
s.assert.NotNil(attr)
s.assert.True(attr.IsDir())
err = s.az.DeleteDir(internal.DeleteDirOptions{Name: "c1"})
s.assert.Nil(err)
// a paths under c1 should be deleted

Просмотреть файл

@ -535,10 +535,17 @@ func split(prefixPath string, path string) string {
return path
}
paths := strings.Split(path, string(os.PathSeparator))
if paths[0] == prefixPath {
// Remove prefixpath from the given path
paths := strings.Split(path, prefixPath)
if paths[0] == "" {
paths = paths[1:]
}
// If result starts with "/" then remove that
if paths[0][0] == '/' {
paths[0] = paths[0][1:]
}
return filepath.Join(paths...)
}

Просмотреть файл

@ -35,6 +35,7 @@ package azstorage
import (
"os"
"path/filepath"
"strconv"
"testing"
@ -75,6 +76,45 @@ type contentTypeVal struct {
result string
}
func (s *utilsTestSuite) TestPrefixPathRemoval() {
assert := assert.New(s.T())
type PrefixPath struct {
prefix string
path string
result string
}
var inputs = []PrefixPath{
{prefix: "", path: "abc.txt", result: "abc.txt"},
{prefix: "", path: "ABC", result: "ABC"},
{prefix: "", path: "ABC/DEF.txt", result: "ABC/DEF.txt"},
{prefix: "", path: "ABC/DEF/1.txt", result: "ABC/DEF/1.txt"},
{prefix: "ABC", path: "ABC/DEF/1.txt", result: "DEF/1.txt"},
{prefix: "ABC/", path: "ABC/DEF/1.txt", result: "DEF/1.txt"},
{prefix: "ABC", path: "ABC/DEF", result: "DEF"},
{prefix: "ABC/", path: "ABC/DEF", result: "DEF"},
{prefix: "ABC/", path: "ABC/DEF/G/H/1.txt", result: "DEF/G/H/1.txt"},
{prefix: "ABC/DEF", path: "ABC/DEF/1.txt", result: "1.txt"},
{prefix: "ABC/DEF/", path: "ABC/DEF/1.txt", result: "1.txt"},
{prefix: "ABC/DEF", path: "ABC/DEF/A/B/c.txt", result: "A/B/c.txt"},
{prefix: "ABC/DEF/", path: "ABC/DEF/A/B/c.txt", result: "A/B/c.txt"},
{prefix: "A/B/C/D/E", path: "A/B/C/D/E/F/G/H/I/j.txt", result: "F/G/H/I/j.txt"},
{prefix: "A/B/C/D/E/", path: "A/B/C/D/E/F/G/H/I/j.txt", result: "F/G/H/I/j.txt"},
}
for _, i := range inputs {
s.Run(filepath.Join(i.prefix, i.path), func() {
output := split(i.prefix, i.path)
assert.EqualValues(i.result, output)
})
}
}
func (s *utilsTestSuite) TestGetContentType() {
assert := assert.New(s.T())
var inputs = []contentTypeVal{