|
@ -2,7 +2,6 @@ package filer2 |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
|
|
|
"strings" |
|
|
"strings" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
@ -24,7 +23,6 @@ type FilerStore interface { |
|
|
DeleteFolderChildren(context.Context, util.FullPath) (err error) |
|
|
DeleteFolderChildren(context.Context, util.FullPath) (err error) |
|
|
ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) |
|
|
ListDirectoryEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int) ([]*Entry, error) |
|
|
ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) ([]*Entry, error) |
|
|
ListDirectoryPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) ([]*Entry, error) |
|
|
ListDirectoryUnSupPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) |
|
|
|
|
|
|
|
|
|
|
|
BeginTransaction(ctx context.Context) (context.Context, error) |
|
|
BeginTransaction(ctx context.Context) (context.Context, error) |
|
|
CommitTransaction(ctx context.Context) error |
|
|
CommitTransaction(ctx context.Context) error |
|
@ -140,29 +138,15 @@ func (fsw *FilerStoreWrapper) ListDirectoryPrefixedEntries(ctx context.Context, |
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "list").Observe(time.Since(start).Seconds()) |
|
|
stats.FilerStoreHistogram.WithLabelValues(fsw.ActualStore.GetName(), "list").Observe(time.Since(start).Seconds()) |
|
|
}() |
|
|
}() |
|
|
entries, err := fsw.ActualStore.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) |
|
|
entries, err := fsw.ActualStore.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) |
|
|
if err == fmt.Errorf("UNSUPPORTED") { |
|
|
|
|
|
entries, err = fsw.ListDirectoryUnSupPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) |
|
|
|
|
|
} |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
for _, entry := range entries { |
|
|
|
|
|
filer_pb.AfterEntryDeserialization(entry.Chunks) |
|
|
|
|
|
} |
|
|
|
|
|
return entries, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) ListDirectoryUnSupPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) { |
|
|
|
|
|
|
|
|
if err.Error() == "UNSUPPORTED" { |
|
|
count := 0 |
|
|
count := 0 |
|
|
notPrefixed, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) |
|
|
notPrefixed, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if prefix == "" { |
|
|
if prefix == "" { |
|
|
return notPrefixed, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entries = notPrefixed |
|
|
|
|
|
} else { |
|
|
var lastFileName string |
|
|
var lastFileName string |
|
|
for count < limit { |
|
|
for count < limit { |
|
|
for _, entry := range notPrefixed { |
|
|
for _, entry := range notPrefixed { |
|
@ -185,6 +169,17 @@ func (fsw *FilerStoreWrapper) ListDirectoryUnSupPrefixedEntries(ctx context.Cont |
|
|
break |
|
|
break |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} else if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
for _, entry := range entries { |
|
|
|
|
|
filer_pb.AfterEntryDeserialization(entry.Chunks) |
|
|
|
|
|
} |
|
|
|
|
|
return entries, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) ListDirectoryUnSupPrefixedEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) { |
|
|
|
|
|
|
|
|
return entries, nil |
|
|
return entries, nil |
|
|
} |
|
|
} |
|
|