Skip to content

Commit 214d3bb

Browse files
authored
Invalidate cache in rm_file (#762)
1 parent 7b192a3 commit 214d3bb

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: s3fs/core.py

+1
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,7 @@ async def _bulk_delete(self, pathlist, **kwargs):
18791879

18801880
async def _rm_file(self, path, **kwargs):
18811881
bucket, key, _ = self.split_path(path)
1882+
self.invalidate_cache(path)
18821883

18831884
try:
18841885
await self._call_s3("delete_object", Bucket=bucket, Key=key)

Diff for: s3fs/tests/test_s3fs.py

+17
Original file line numberDiff line numberDiff line change
@@ -2636,3 +2636,20 @@ async def read_stream():
26362636

26372637
asyncio.run(read_stream())
26382638
assert b"".join(out) == data
2639+
2640+
2641+
def test_rm_invalidates_cache(s3):
2642+
# Issue 761: rm_file does not invalidate cache
2643+
fn = test_bucket_name + "/2014-01-01.csv"
2644+
assert s3.exists(fn)
2645+
assert fn in s3.ls(test_bucket_name)
2646+
s3.rm(fn)
2647+
assert not s3.exists(fn)
2648+
assert fn not in s3.ls(test_bucket_name)
2649+
2650+
fn = test_bucket_name + "/2014-01-02.csv"
2651+
assert s3.exists(fn)
2652+
assert fn in s3.ls(test_bucket_name)
2653+
s3.rm_file(fn)
2654+
assert not s3.exists(fn)
2655+
assert fn not in s3.ls(test_bucket_name)

0 commit comments

Comments
 (0)