feat: allow self renamer to work if tempdir is on a different device#797
feat: allow self renamer to work if tempdir is on a different device#797davidkna wants to merge 4 commits into
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #797 +/- ##
========================================
- Coverage 6.81% 2.29% -4.52%
========================================
Files 37 30 -7
Lines 11820 4566 -7254
========================================
- Hits 806 105 -701
+ Misses 11014 4461 -6553 ☔ View full report in Codecov by Sentry. |
SteveLauC
left a comment
There was a problem hiding this comment.
Hi, thanks for your contributing to Topgrade!
I wonder can we do std::fs::copy(); std::fs::remove_file() here?
It would be possible to use this, but |
|
Yeah, that is one benefit of May I step back a little bit, and ask you what is the functionality of this From my understanding, the renamer itself is simply doing a round-trip, I do not quite get why it is necessary on Windows. |
|
@SteveLauC The self-renamer is supposed to make self-upgrades on Windows work because executable files are locked while they are running and cannot be changed. That likely means that Looking at the surrounding code, this doesn't clean up the old executable on exit in the case of upgrade. With this new case using the binary directory, leaving the temporary executable in-place should be avoided, so I will convert this PR to a draft. |
b4372ee to
d1e5373
Compare
|
Executable cleanup is now implemented via the The clippy issues seem to be unrelated, but I can add fixes for those if preferred. |
From PR topgrade-rs#797. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Standards checklist:
CONTRIBUTING.mdcargo build)cargo fmt)cargo clippy)cargo test)For new steps
--dry-runoption works with this step--yesoption works with this step if it is supported bythe underlying command
Currently, the self renamer fails with the following error if the tempdir is on a different device from the system temporary directory:
This PR works around this by using a temporary file in the binary directory instead in that case.
If you developed a feature or a bug fix for someone else and you do not have the
means to test it, please tag this person here.