Skip to content

Commit

Permalink
Be sure to invalidate cache for both branched of pipe_file
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Oct 20, 2024
1 parent 7fea0f5 commit aa18aa6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion s3fs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ async def _pipe_file(
size = len(data)
# 5 GB is the limit for an S3 PUT
if size < min(5 * 2**30, 2 * chunksize):
return await self._call_s3(
await self._call_s3(
"put_object", Bucket=bucket, Key=key, Body=data, **kwargs
)
else:
Expand Down
10 changes: 10 additions & 0 deletions s3fs/tests/test_s3fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2802,3 +2802,13 @@ def test_upload_part_with_prime_pads(s3_fixed_upload_size):

with s3_fixed_upload_size.open(a, "r") as f:
assert len(f.read()) == 2 * block + pad1 + pad2


@pytest.mark.asyncio
async def test_invalidate_cache(s3: s3fs.S3FileSystem) -> None:
await s3._call_s3("put_object", Bucket=test_bucket_name, Key="a/b.txt", Body=b"abc")
before = await s3._ls(f"{test_bucket_name}/a/")
assert sorted(before) == ["test/a/b.txt"]
await s3._pipe_file(f"{test_bucket_name}/a/c.txt", data=b"abc")
after = await s3._ls(f"{test_bucket_name}/a/")
assert sorted(after) == ["test/a/b.txt", "test/a/c.txt"]

0 comments on commit aa18aa6

Please sign in to comment.