Skip to content

Fix local cache not cleared after mutating operations#562

Open
Gardner-Programs wants to merge 1 commit into
drivendataorg:masterfrom
Gardner-Programs:fix/cache-invalidation-on-mutate
Open

Fix local cache not cleared after mutating operations#562
Gardner-Programs wants to merge 1 commit into
drivendataorg:masterfrom
Gardner-Programs:fix/cache-invalidation-on-mutate

Conversation

@Gardner-Programs
Copy link
Copy Markdown

Summary

Fixes #388.

When files or directories are deleted or moved via unlink, replace, rename, rmdir, or rmtree, the local cache was not being cleared. This caused stale cached files to persist on disk, leading to errors or incorrect data on subsequent access.

  • Added self.clear_cache() after _remove in unlink and rmdir
  • Added self.clear_cache() and target.clear_cache() after _move_file in replace (rename delegates to replace and gets the fix for free)
  • Added self.clear_cache() after _remove in rmtree

Note: rmdir on Azure and S3 may behave unexpectedly with empty directories since those providers don't persist empty directory objects. This is a pre-existing limitation unrelated to this fix.

Test plan

  • Added test_cache_cleared_after_mutation to tests/test_caching.py covering unlink, replace, and rmtree across all supported providers
  • All 140 caching tests pass
  • All file I/O and manipulation tests pass

…ir, rmtree)

Closes drivendataorg#388. After each mutating operation, clear_cache() is now called
on affected paths so stale local cache entries don't cause errors on
subsequent access.

Note: rmdir on Azure and S3 may behave unexpectedly with empty directories
since those providers don't persist empty directory objects. This is a
pre-existing limitation unrelated to this fix.
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.

Methods that move/remove files on the cloud don't remove the cached version

1 participant