fix(global): clean stale global package installs on upgrade#1943
fix(global): clean stale global package installs on upgrade#1943liangmiQwQ wants to merge 3 commits into
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 004a2a241a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let has_install_id = name | ||
| .rfind(INSTALL_ID_PREFIX) | ||
| .is_some_and(|index| index > 0 && is_install_id(&name[index..])); | ||
| if !has_install_id || active_install_dirs.contains(path) { |
There was a problem hiding this comment.
Guard against deleting in-progress installs
If vp upgrade runs while another vp install -g is between creating packages/<pkg>#<uuid> in install_one and saving its PackageMetadata, this check treats that live directory as inactive and the cleanup removes it. The install can then continue and write metadata/shims pointing at a package directory that no longer exists, so stale cleanup needs an age/lock/coordination check before deleting identified dirs.
Useful? React with 👍 / 👎.
|
I have a better solution, we can maintain a |
The current global install cleanup only removes the install directory recorded by previous metadata. If a reinstall is interrupted, unrecorded package directories can stay behind, and the legacy empty install-id package directory can also survive. This PR keeps a file lock for each in-progress global package install directory, then replaces the previous-install cleanup with a same-package stale directory sweep. The sweep skips locked directories so concurrent global installs are protected, and removes both `package#installId` stale directories and the empty install-id layout. Related: - #1906 (comment) - #1943 (comment) 🤖 Generated with Codex.
The current global package install flow can leave inactive
packages/<name>#<uuid>directories behind when an install is interrupted before metadata activation. Older legacy installs can also leave inactivepackages/<name>directories without an install ID.This PR makes
vp upgraderun a best-effort cleanup for stale global package install directories. It preserves every active install directory recorded in metadata, including legacy installs whereinstallIdis empty, removes inactive identified and legacy install directories once they are old enough, and leaves malformed#...names alone.Recent inactive install directories are kept so a concurrent
vp install -gthat has created its package prefix but not saved metadata yet cannot be deleted by upgrade cleanup.🤖 Generated with Codex.