Skip to content

Commit

Permalink
Avoid adding parent dir in find
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Durant committed Jan 14, 2021
1 parent 8f1684d commit 38bceee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
21 changes: 11 additions & 10 deletions s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,16 +561,17 @@ async def _find(self, path, maxdepth=None, withdirs=None, detail=False):
if par not in self.dircache:
if par not in sdirs:
sdirs.add(par)
dirs.append(
{
"Key": self.split_path(par)[1],
"Size": 0,
"name": par,
"StorageClass": "DIRECTORY",
"type": "directory",
"size": 0,
}
)
if len(path) <= len(par):
dirs.append(
{
"Key": self.split_path(par)[1],
"Size": 0,
"name": par,
"StorageClass": "DIRECTORY",
"type": "directory",
"size": 0,
}
)
self.dircache[par] = []
if par in sdirs:
self.dircache[par].append(o)
Expand Down
5 changes: 3 additions & 2 deletions s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,11 @@ def test_copy_managed(s3):
sync(s3.loop, s3._copy_managed, fn, fn + "3", size=len(data), block=6 * 2 ** 30)


def test_move(s3):
@pytest.mark.parametrize("recursive", [True, False])
def test_move(s3, recursive):
fn = test_bucket_name + "/test/accounts.1.json"
data = s3.cat(fn)
s3.mv(fn, fn + "2")
s3.mv(fn, fn + "2", recursive=recursive)
assert s3.cat(fn + "2") == data
assert not s3.exists(fn)

Expand Down

0 comments on commit 38bceee

Please sign in to comment.