-
Notifications
You must be signed in to change notification settings - Fork 625
feat: create CACHEDIR.TAG file in .lake directory #5059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Create CACHEDIR.TAG file in .lake directory when it is first created. The file does not get recreated if removed if .lake directory is not removed, too. While technically against the spec, this is how Rust does it, too. Moreover, this simplifies the implementation a lot. This change also introduces a test to check that the file gets cretead but not recreated. This test needs to change e.g. if we decide that CACHEDIR.TAG should always be recreated.
Mathlib CI status (docs):
|
Marking this as non-draft as I noticed that @tydeu has initially approved the idea on Zulip. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to me! I have one major suggested change, but, nonetheless, great job! I really like the detailed test. 😄
-- Create CACHEDIR.TAG file only when .lake directory is first created | ||
IO.FS.writeFile (cfg.lakeDir / "CACHEDIR.TAG") cachedirTagContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really what this this does. If a user deletes the CACHEDIR.TAG
(because they wish the directory to be cached) and then, unrelatedly, delete the configuration trace (e.g., due to an incomplete configuration), this will regenerate the CACHEDIR.TAG
(which would be quite surprising behavior).
Now that creating the lake directory is something worth doing independently, I suggest refactoring out the cfg.lakeDir
creation here to the top of this function (outside all the locking). That is, just add something like this to the top and remove it from here:
if !(<- cfg.lakeDir.pathExists) then
IO.FS.createDirAll cfg.lakeDir
-- Create CACHEDIR.TAG file only when .lake directory is first created
IO.FS.writeFile (cfg.lakeDir / "CACHEDIR.TAG") cachedirTagContent
|
||
$LAKE new hello | ||
test ! -e hello/.lake | ||
# Building craetes CACHEDIR.TAG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Building craetes CACHEDIR.TAG | |
# Building creates CACHEDIR.TAG |
# Removing CACHEDIR.TAG without removing .lake directory and then rebuilding | ||
# does not currently recreate CACHEDIR.TAG. This is an artifact of the current | ||
# implementation and is technically against the spec: | ||
# | ||
# > The application should also regenerate the cache directory tag if it | ||
# > disappears -- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an odd spec requirement that does not seem desirable. A user may wish to remove the tag and cache the directory and Lake should not override that.
Create CACHEDIR.TAG file in .lake directory when it is first created. The file does not get recreated if removed if .lake directory is not removed, too. While technically against the spec, this is how Rust does it, too. Moreover, this simplifies the implementation a lot.
This change also introduces a test to check that the file gets cretead but not recreated. This test needs to change e.g. if we decide that CACHEDIR.TAG should always be recreated.
Closes #4998