Skip to content

Commit

Permalink
local: only walk the subdirectory designated by prefix
Browse files Browse the repository at this point in the history
When listing items using the local-file-system driver, only
traverse the subdirectory with longest prefix that contains
the given listing prefix.

Three cases are of interest:

a. The listing prefix is foo/bar/ - we walk subdirectory foo/bar
   under the container's path.
b. The listing prefix is foo/ba - we walk subdirectory foo under
   the container's path, and filter stuff that doesn't begin with
   foo/ba.
c. The prefix is an empty string - walk the container's path like
   today.
  • Loading branch information
urisimchoni committed Apr 30, 2020
1 parent 5090362 commit 988b9a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion local/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ func (c *container) Put(name string, r io.Reader, size int64, metadata map[strin

func (c *container) Items(prefix, cursor string, count int) ([]stow.Item, string, error) {
prefix = filepath.FromSlash(prefix)
files, err := flatdirs(c.path)
walkBase := c.path
if prefix != "" {
walkBase = filepath.Dir(filepath.Join(c.path, prefix))
}
files, err := flatdirs(walkBase)
if err != nil {
return nil, "", err
}
Expand Down

0 comments on commit 988b9a3

Please sign in to comment.