Skip to content

storage/fs: change order of precedence for URL expansion - #322

Merged
sonmezonur merged 4 commits into
masterfrom
fs_list_glob
Jul 26, 2021
Merged

sonmezonur merged 4 commits into
masterfrom
fs_list_glob

Conversation

@sonmezonur

Copy link
Copy Markdown
Member
  • Glob(*) expansion must have precedence over directory expansion.

If the source URL is both glob and directory, s5cmd only copies objects in the directory. Example setup:

testdir
|-- abc*
|   |-- file1.txt
|   `-- file2.txt
`-- abcd
    |-- file1.txt
    `-- file2.txt
❯ s5cmd cp 'testdir/abc*' s3://bigtmp/prefix/
cp testdir/abc*/file2.txt s3://bigtmp/prefix/abc*/file2.txt
cp testdir/abc*/file1.txt s3://bigtmp/prefix/abc*/file1.txt

URL expansion for fs.List() is working like following:

1) if given source URL is a directory, it only walks the directory.
2) if given source URL has glob, it expands glob.
3) if given source is not glob or directory, it sends stat call to single file.

Since abc* is a directory, currently s5cmd does not try to expand glob. I think we should change the order of precedence for dir/glob expansion.

I added tests for both cp/rm commands.

* Glob(*) expansion must have precedence over directory expansion.
@sonmezonur
sonmezonur requested review from a team, aykutfarsak and ilkinulas and removed request for a team July 13, 2021 15:24
@sonmezonur
sonmezonur merged commit 4130a7e into master Jul 26, 2021
@sonmezonur
sonmezonur deleted the fs_list_glob branch July 26, 2021 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants