SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
handle directory listing edge cases
Chris Lufe46411cd4e6
diff --git a/weed/filer/filerstore_translate_path.go b/weed/filer/filerstore_translate_path.goindex b40e32d3d4..4ea69ea8db 100644--- a/weed/filer/filerstore_translate_path.go+++ b/weed/filer/filerstore_translate_path.go@@ -30,12 +30,23 @@ func NewFilerStorePathTranlator(storeRoot string, store FilerStore) *FilerStoreP}}+func (t *FilerStorePathTranlator) translatePath(fp util.FullPath) (newPath util.FullPath){+ newPath = fp+ if t.storeRoot == "/" {+ return+ }+ newPath = fp[len(t.storeRoot)-1:]+ if newPath == "" {+ newPath = "/"+ }+ return+}func (t *FilerStorePathTranlator) changeEntryPath(entry *Entry) (previousPath util.FullPath){previousPath = entry.FullPathif t.storeRoot == "/" {return}- entry.FullPath = previousPath[len(t.storeRoot)-1:]+ entry.FullPath = t.translatePath(previousPath)return}func (t *FilerStorePathTranlator) recoverEntryPath(entry *Entry, previousPath util.FullPath) {@@ -68,7 +79,7 @@ func (t *FilerStorePathTranlator) FindEntry(ctx context.Context, fp util.FullPatif t.storeRoot == "/" {return t.actualStore.FindEntry(ctx, fp)}- newFullPath := fp[len(t.storeRoot)-1:]+ newFullPath := t.translatePath(fp)entry, err = t.actualStore.FindEntry(ctx, newFullPath)if err == nil {entry.FullPath = fp[:len(t.storeRoot)-1] + entry.FullPath@@ -77,7 +88,7 @@ func (t *FilerStorePathTranlator) FindEntry(ctx context.Context, fp util.FullPat}func (t *FilerStorePathTranlator) DeleteEntry(ctx context.Context, fp util.FullPath) (err error) {- newFullPath := fp[len(t.storeRoot)-1:]+ newFullPath := t.translatePath(fp)return t.actualStore.DeleteEntry(ctx, newFullPath)}@@ -90,14 +101,14 @@ func (t *FilerStorePathTranlator) DeleteOneEntry(ctx context.Context, existingEn}func (t *FilerStorePathTranlator) DeleteFolderChildren(ctx context.Context, fp util.FullPath) (err error) {- newFullPath := fp[len(t.storeRoot)-1:]+ newFullPath := t.translatePath(fp)return t.actualStore.DeleteFolderChildren(ctx, newFullPath)}func (t *FilerStorePathTranlator) ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) {- newFullPath := dirPath[len(t.storeRoot)-1:]+ newFullPath := t.translatePath(dirPath)entries, err := t.actualStore.ListDirectoryEntries(ctx, newFullPath, startFileName, includeStartFile, limit)if err != nil {@@ -111,7 +122,7 @@ func (t *FilerStorePathTranlator) ListDirectoryEntries(ctx context.Context, dirPfunc (t *FilerStorePathTranlator) ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) ([]*Entry, error) {- newFullPath := dirPath[len(t.storeRoot)-1:]+ newFullPath := t.translatePath(dirPath)entries, err := t.actualStore.ListDirectoryPrefixedEntries(ctx, newFullPath, startFileName, includeStartFile, limit, prefix)if err != nil {diff --git a/weed/filer/filerstore_wrapper.go b/weed/filer/filerstore_wrapper.goindex ba26ca41ba..011bab963a 100644--- a/weed/filer/filerstore_wrapper.go+++ b/weed/filer/filerstore_wrapper.go@@ -237,7 +237,7 @@ func (fsw *FilerStoreWrapper) ListDirectoryPrefixedEntries(ctx context.Context,}func (fsw *FilerStoreWrapper) prefixFilterEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) {- actualStore := fsw.getActualStore(dirPath)+ actualStore := fsw.getActualStore(dirPath+"/")entries, err = actualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit)if err != nil {return nil, err