Skip to content
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

Mark $CARGO_HOME/{registry,git} as cache directories #8974

Closed
wants to merge 1 commit into from

Conversation

jstasiak
Copy link
Contributor

This follows GH-8378 which applies this technique to target directories
inside projects. With the patch two large-ish throwaway directories are
also excluded from backups.

I decided against excluding $CARGO_HOME/bin or $CARGO_HOME as a whole,
because there may be important binaries needed by a user to run their
system and there are credentials in the credentials file – I'm happy to
simplify this and exclude whole $CARGO_HOME though.

I'm less happy with this than I was with GH-8378 – I don't see a particularly nice way to provide an automated test this addition, I welcome guidance on this matter.

This follows rust-langGH-8378 which applies this technique to target directories
inside projects. With the patch two large-ish throwaway directories are
also excluded from backups.

I decided against excluding $CARGO_HOME/bin or $CARGO_HOME as a whole,
because there may be important binaries needed by a user to run their
system and there are credentials in the credentials file – I'm happy to
simplify this and exclude whole $CARGO_HOME though.
@rust-highfive
Copy link

r? @ehuss

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 13, 2020
@alexcrichton
Copy link
Member

Thanks for this! One thing that feels a bit odd is that looking at the surrounding context it's not clear why these paths are the way they are since the code working with directories isn't using the same path names. Is it possible to perhaps move creation of the backup attributes closer to where these path names are originally created?

@jstasiak
Copy link
Contributor Author

Yeah that's a fair note and also why I'm not happy with this but I'm also a bit out of my depth concerning the cargo codebase.

As far as I understand it's actually those two pieces of code that create $CARGO_HOME/registry and $CARGO_HOME/git through the paths::create_dir_all(&path)?; and paths::create_dir_all(&into)?; calls right below my additions (path and into contain $CARGO_HOME/registry/.../... and $CARGO_HOME/git/.../...). I believe there's no dedicated code to create those registry and git directories and they're created right here.

I'm not sure what's the best way to move forward here. The alternatives I see are:

  • Add this new directory-creation-and-exclusion code to places where GitRemote::checkout() and RemoteRegistry::repo() are called instead of those methods themselves
  • Find some function that's always called before any registry and git manipulation takes place and add this code there

In both cases I think paths::create_dir_all(...) would need to disappear from GitRemote::checkout() and RemoteRegistry::repo() because if we forgot to create $CARGO_HOME/registry or $CARGO_HOME/git before the methods are called then calling paths::create_dir_all(...) would create them but not exclude them, thus silently doing something undesired.

@jstasiak
Copy link
Contributor Author

I just confirmed with an empty $CARGO_HOME that the code is working as expected (registry/ and git/ have CACHEDIR.TAG in them). But I also realized that I read your question

Is it possible to perhaps move creation of the backup attributes closer to where these path names are originally created?

as

Is it possible to perhaps move creation of the backup attributes closer to where these paths are originally created?

which is, well, different enough.

Yeah, I suppose the code that determines what's the name of the registry directory could be doing the creation and exclusion, I'll look into it.

@ehuss
Copy link
Contributor

ehuss commented Aug 6, 2021

I'm gonna close this due to inactivity. Feel free to reopen or create a new PR when you've got time to work on this again. Thanks!

@ehuss ehuss closed this Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants