fix(installer): prevent deletion of current manifest in Bash version

Issue:
- In Bash version, new_install_manifest creates file immediately
- save_install_manifest calls remove_old_manifests_for_path
- This deletes ALL manifests for the path, including the new one
- Result: "WARNING: Failed to save installation manifest"

Solution:
- Add current_manifest_file parameter to remove_old_manifests_for_path
- Skip deletion if file matches current manifest
- Pass manifest_file to exclude it from deletion

Note: PowerShell version does not have this issue because it creates
the manifest file AFTER deleting old ones (hashtable → file conversion)
This commit is contained in:
catlog22
2025-11-17 22:51:14 +08:00
parent 3f7db2fdbc
commit b4e09213e4

View File

@@ -976,6 +976,7 @@ EOF
function remove_old_manifests_for_path() {
local installation_path="$1"
local current_manifest_file="$2" # Optional: exclude this file from deletion
if [ ! -d "$MANIFEST_DIR" ]; then
return 0
@@ -987,6 +988,11 @@ function remove_old_manifests_for_path() {
# Find and remove old manifests for the same installation path
while IFS= read -r -d '' file; do
# Skip the current manifest file if specified
if [ -n "$current_manifest_file" ] && [ "$file" = "$current_manifest_file" ]; then
continue
fi
local manifest_path=$(jq -r '.installation_path // ""' "$file" 2>/dev/null)
if [ -n "$manifest_path" ]; then
@@ -1013,9 +1019,9 @@ function save_install_manifest() {
local manifest_file="$1"
local installation_path="$2"
# Remove old manifests for the same installation path
# Remove old manifests for the same installation path (excluding current one)
if [ -n "$installation_path" ]; then
remove_old_manifests_for_path "$installation_path"
remove_old_manifests_for_path "$installation_path" "$manifest_file"
fi
if [ -f "$manifest_file" ]; then