nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

Make handling of existing clones more robust #127

Closed bbannier closed 4 years ago

bbannier commented 4 years ago

Since by default we e.g., clone projects into $TEMPDIR, it can happen that previous clones get partially reaped. This can lead to existing, but invalid clones.

Previously we always assumed that a clone either does not exist (and needs to be fully pulled again), or if it exists is valid (and we can e.g., simply update it). This is not true if e.g., the git folder was reaped to such an extent that the clone is broken.

This patch updates our handling to use a slightly modified flow. We first try to open a repository at the expected location (meaning it both existed and is valid), or when that fails perform a fresh clone (removing any existing clone folder). This allows us to handle a wider range of failure scenarios (e.g., git directory in clone partially reaped; some permission changes on clone like clone being not readable).

bbannier commented 4 years ago

Thanks for the quick turnaround!

Sorry for the bad formatting. I had some trouble getting either rustfmt 1.4.11-stable (18382352 2019-12-03) or rustfmt 1.4.12-nightly (9f53665f 2020-02-10) to accept the config file,

Warning: Unknown configuration option `fn_args_density`
Warning: Unknown configuration option `fn_args_paren_newline`
Warning: Unknown configuration option `fn_call_width`
Warning: Unknown configuration option `ideal_width`
Warning: Unknown configuration option `struct_trailing_comma`
nabijaczleweli commented 4 years ago

No worries, I use an archaic version of rustfmt dated Apr 29, 2017 following a philosophical disagreement with one of the newer versions some time back, so this is perfectly fine :Р

P:\Rust\cargo-update>rustfmt --version
0.7.1 ()
nabijaczleweli commented 4 years ago

Released in v2.5.3.