mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-09 06:28:59 +02:00
fix(upgrade): abort when a stale .bak already exists at the install path
A leftover $INSTALL_DIR.bak from a crashed upgrade would make the mv nest the live install inside it, and the failure-restore arm would 'restore' the stale backup — possibly deleting the only good copy. The upgrade now refuses to start and tells the user to inspect/salvage the backup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
c0db2670f8
commit
c9e662d802
@@ -170,6 +170,11 @@ If `$STASH_OUTPUT` contains "Saved working directory", warn the user: "Note: loc
|
||||
**For vendored installs** (vendored, vendored-global):
|
||||
```bash
|
||||
PARENT=$(dirname "$INSTALL_DIR")
|
||||
# A stale .bak from a previously crashed upgrade would make the mv below NEST
|
||||
# the live install inside it and the failure-restore arm would "restore" the
|
||||
# stale backup. It may also be the only good copy from that crashed run —
|
||||
# abort and let the human inspect, never delete it silently.
|
||||
[ -e "$INSTALL_DIR.bak" ] && { echo "ERROR: stale backup exists at $INSTALL_DIR.bak (from a previous failed upgrade?) — inspect it, salvage/remove it, then re-run." >&2; exit 1; }
|
||||
TMP_DIR=$(mktemp -d) || { echo "ERROR: mktemp failed — aborting upgrade (install untouched)." >&2; exit 1; }
|
||||
git clone --depth 1 https://github.com/garrytan/gstack.git "$TMP_DIR/gstack" || { echo "ERROR: clone failed — aborting upgrade (install untouched)." >&2; rm -rf "$TMP_DIR"; exit 1; }
|
||||
mv "$INSTALL_DIR" "$INSTALL_DIR.bak"
|
||||
|
||||
@@ -167,6 +167,11 @@ If `$STASH_OUTPUT` contains "Saved working directory", warn the user: "Note: loc
|
||||
**For vendored installs** (vendored, vendored-global):
|
||||
```bash
|
||||
PARENT=$(dirname "$INSTALL_DIR")
|
||||
# A stale .bak from a previously crashed upgrade would make the mv below NEST
|
||||
# the live install inside it and the failure-restore arm would "restore" the
|
||||
# stale backup. It may also be the only good copy from that crashed run —
|
||||
# abort and let the human inspect, never delete it silently.
|
||||
[ -e "$INSTALL_DIR.bak" ] && { echo "ERROR: stale backup exists at $INSTALL_DIR.bak (from a previous failed upgrade?) — inspect it, salvage/remove it, then re-run." >&2; exit 1; }
|
||||
TMP_DIR=$(mktemp -d) || { echo "ERROR: mktemp failed — aborting upgrade (install untouched)." >&2; exit 1; }
|
||||
git clone --depth 1 https://github.com/garrytan/gstack.git "$TMP_DIR/gstack" || { echo "ERROR: clone failed — aborting upgrade (install untouched)." >&2; rm -rf "$TMP_DIR"; exit 1; }
|
||||
mv "$INSTALL_DIR" "$INSTALL_DIR.bak"
|
||||
|
||||
Reference in New Issue
Block a user