dune icon indicating copy to clipboard operation
dune copied to clipboard

chore: Add Cache Directory Tagging Specification

Open H-ANSEN opened this issue 1 year ago • 6 comments

This pull requests closes #9054 implementing the format specification found at https://bford.info/cachedir/.

I opted to follow @Alizter's specification in the issue only creating the CACHEDIR.TAG file when the default directory for the dune cache is being used. So if the environment variable DUNE_CACHE_ROOT is set this file will not be generated! Additionally, I omitted adding comments to the file but the specification does say that comments beginning with a # character are permitted after the signature, giving the following example:

Signature: 8a477f597d28d172789f06886806bc55
# This file is a cache directory tag created by (application name).
# For information about cache directory tags, see:
#	http://www.brynosaurus.com/cachedir/

H-ANSEN avatar Jul 16 '24 16:07 H-ANSEN

out of curiosity, what tool do you use that honors this specification?

emillon avatar Jul 17 '24 09:07 emillon

My original motivation was rsync

Alizter avatar Jul 17 '24 10:07 Alizter

the spec says rsync could one day use this, but it doesn't seem that it has ever been implemented.

emillon avatar Jul 17 '24 10:07 emillon

out of curiosity, what tool do you use that honors this specification?

I used tar on Linux with each of the following commands to package up my whole cache folder:

  • --exclude-caches
  • --exclude-caches-all
  • --exclude-caches-under

H-ANSEN avatar Jul 17 '24 11:07 H-ANSEN

I'm not opposed to that feature if there's actual demand for it and it fixes a use case, but at the moment it looks like the spec is only implemented by gnu tar, and there are other ways to achieve this without modifying dune (in particular, since it's only added when the cache is in XDG_CACHE_HOME, why not ignore the whole cache dir?).

To put it differently, the issue is tagged good-first-issue but I think this requires some validation first.

emillon avatar Jul 17 '24 11:07 emillon

Yea.. I totally see what you mean. There could be an argument made that it makes more sense to include the tagging file when the cache directory is moved from its default. I don't think I can provide much more validation, I mostly went after this issue since it was marked good-first-issue.

H-ANSEN avatar Jul 17 '24 11:07 H-ANSEN

Popular backup tools like restic (since 2017), borg (since 2014) and duplicati (since 2018) support CACHEDIR.TAG.

It should always be added when the dune cache directory is created, no matter whether in the default or custom location.

madroach avatar Aug 19 '25 16:08 madroach

No objection to this feature if anybody cares enough to revive it.

rgrinberg avatar Aug 19 '25 22:08 rgrinberg