Closed t-mw closed 3 years ago
@t-mw after this change, running the example on my windows machine is giving me a permissions error
cargo run --example github --features "archive-tar archive-zip compression-flate2 compression-zip-deflate"
... snip ...
Do you want to continue? [Y/n] Y
Downloading...
[00:00:00] [========================================] 1.09MB/1.09MB (0s) Done
Extracting archive... Done
Replacing binary file... [ERROR] IoError: Access is denied. (os error 5)
error: process didn't exit successfully: target\debug\examples\github.exe (exit code: 1)
Any ideas?
Looks like it's failing on the fs::rename(temp, dest)?;
for some reason
interestingly, it works if I revert only the first copy back to a rename
seems like the removal of env::var_os("TEMP")
was the real fix, so I'm going to revert rename->copy change before I do a release
Sorry, I see the same error and thought I'd fixed it after testing with my own project. Reverting to rename is fine, but it prevents the temporary file from being cleaned up. I think TEMP
was being used as a workaround, but that creates the issues with not being able to update on non-C: drives.
released in 0.25.0
Thanks. Not ideal that those temp folders build up on Windows now. Reading around it seems like the only way to avoid that is to delete them when the updated executable runs. I could work on that if that sounds ok.
Fixes https://github.com/jaemk/self_update/issues/67.
I'm not sure why
TEMP
is required on Windows, but it might've been to force the temp file to be cleaned up by the OS. Thetempfile
crate should have been doing this even outside theTEMP
directory, but couldn't because the running executable was still referencing the temp file at the time thattempfile::TempDir
was dropped. I've tested on Windows and this PR seems to fix those issues, andfs::rename(self.source, dest);
still works when overwriting the file of the running executable.