Tag cache directories with CACHEDIR.TAG - #373
Open
hikmetba-bit wants to merge 1 commit into
Open
hikmetba-bit wants to merge 1 commit into
hikmetba-bit wants to merge 1 commit into
Conversation
Fixes grantjenks#352. Writes a standard CACHEDIR.TAG file (https://bford.info/cachedir/) into each Cache directory on init, so backup tools (rsync --cvs-exclude, tar --exclude-caches, etc.) can skip disposable cache data. FanoutCache shards get one too, since each shard is itself a Cache instance. The write is best-effort (an OSError, e.g. a read-only directory, is swallowed) and idempotent ('xb' exclusive-create, skipped if the tag already exists). Cache.check()'s "unknown file" scan also needed to ignore the tag file, the same way it already ignores the sqlite DBNAME files, otherwise check(fix=True) would delete it as an untracked file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #352.
Writes a standard CACHEDIR.TAG file into each
Cachedirectory on init, so backup and archiving tools that understand the convention (rsync --cvs-exclude,tar --exclude-caches-all, some backup GUIs, etc.) can skip disposable cache data automatically.FanoutCacheshards each get one too, since every shard is itself aCacheinstance created in the same__init__, so no separate change was needed there.Details
'xb') so it's a no-op if the tag already exists, and anyOSError(e.g. a read-only cache directory) is swallowed — this is a best-effort convenience file, not something that should ever break cache initialization.Cache.check()'s "unknown file" scan needed a matching change: it already special-cases the sqliteDBNAMEfiles so they aren't flagged/removed as untracked files, andCACHEDIR.TAGneeded the same treatment, otherwisecheck(fix=True)would delete it.Test plan
test_cachedir_tagintests/test_core.py: asserts the tag file exists with the correct standard signature afterCache()init, and thatcache.check(fix=True)neither warns about it nor removes it.pytest tests/test_core.py tests/test_fanout.py: 130 passed, no regressions.🤖 Generated with Claude Code