-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
caddycmd: Add --keep-backup
to upgrade commands
#4387
Conversation
a303a86
to
8ae6a24
Compare
26e5f51
to
21d1b96
Compare
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong.
The error message "download succeeded, but unable to execute" was repeated, because it was both in the `listModules`/`showVersion` functions and in the calling `upgradeBuild` function. Oversight when this was refactored.
Without this, the cleanup operation would fail with an error message like this: upgrade: download succeeded, but unable to clean up backup binary: remove C:\caddy\caddy.exe.tmp: Access is denied.
21d1b96
to
afe012a
Compare
Hmm, what if we always left a backup file called |
Hmm, I think it's best to clean up by default, because it's not so nice to leave things around in |
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.
Okay, that's fine. My only nit might be could we make the flag name a little clearer / more obvious? Maybe --keep-backup
instead of --skip-cleanup
.
--skip-cleanup
to upgrade commands--keep-backup
to upgrade commands
bbeab20
to
cd59a03
Compare
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.
LGTM, thank you -- let's give this a try
This is a partial fix for #4057, making it possible to retain the old build of Caddy, in case something went wrong, with the
--keep-backup
flag.Also includes two additional issues I noticed while reviewing/testing:
There was a duplicate error message being printed if something went wrong when running
caddy list-modules
orcaddy version
, just an oversight during the recent refactor.Running
os.Remove
to cleanup the renamed backup binary actually fails on Windows, because that's a program trying to remove itself. It's possible to work around this by runningcmd.exe /C del <file>
which adds a layer of inversion so that it's actually a different process that deletes the file.