|
@ -145,44 +145,47 @@ func (fsw *FilerStoreWrapper) ListDirectoryPrefixedEntries(ctx context.Context, |
|
|
}() |
|
|
}() |
|
|
entries, err := fsw.ActualStore.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) |
|
|
entries, err := fsw.ActualStore.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, prefix) |
|
|
if err == ErrUnsupportedListDirectoryPrefixed { |
|
|
if err == ErrUnsupportedListDirectoryPrefixed { |
|
|
count := 0 |
|
|
|
|
|
notPrefixed, err := fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, startFileName, includeStartFile, limit) |
|
|
|
|
|
|
|
|
entries, err = fsw.prefixFilterEntries(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) prefixFilterEntries(ctx context.Context, dirPath util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*Entry, err error) { |
|
|
|
|
|
entries, 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 == "" { |
|
|
entries = notPrefixed |
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
count := 0 |
|
|
var lastFileName string |
|
|
var lastFileName string |
|
|
for count < limit { |
|
|
|
|
|
|
|
|
notPrefixed := entries |
|
|
|
|
|
entries = nil |
|
|
|
|
|
for count < limit && len(notPrefixed) > 0 { |
|
|
for _, entry := range notPrefixed { |
|
|
for _, entry := range notPrefixed { |
|
|
lastFileName = entry.Name() |
|
|
lastFileName = entry.Name() |
|
|
if strings.HasPrefix(entry.Name(), prefix) { |
|
|
if strings.HasPrefix(entry.Name(), prefix) { |
|
|
count++ |
|
|
count++ |
|
|
entries = append(entries, entry) |
|
|
entries = append(entries, entry) |
|
|
} |
|
|
} |
|
|
if count >= limit { |
|
|
|
|
|
goto Exit |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
notPrefixed, err = fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, lastFileName, false, limit) |
|
|
|
|
|
|
|
|
if count < limit { |
|
|
|
|
|
notPrefixed, err = fsw.ActualStore.ListDirectoryEntries(ctx, dirPath, lastFileName, false, limit-count) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(notPrefixed) == 0 { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
Exit: |
|
|
|
|
|
} |
|
|
} |
|
|
} else if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
} |
|
|
for _, entry := range entries { |
|
|
|
|
|
filer_pb.AfterEntryDeserialization(entry.Chunks) |
|
|
|
|
|
} |
|
|
|
|
|
return entries, nil |
|
|
|
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (fsw *FilerStoreWrapper) BeginTransaction(ctx context.Context) (context.Context, error) { |
|
|
func (fsw *FilerStoreWrapper) BeginTransaction(ctx context.Context) (context.Context, error) { |
|
|