Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/forge.func
Original file line number Diff line number Diff line change
Expand Up @@ -2120,12 +2120,18 @@ fetch_and_deploy_release() {
# redo (ProxmoxVE #18050).
CS_PREVIOUS_VERSION="$(_forge_previous_version "$version_file")"
export CS_PREVIOUS_VERSION
[[ -f "${version_file}.pending" ]] || printf '%s' "$CS_PREVIOUS_VERSION" >"${version_file}.pending" 2>/dev/null || true
# A redo deploys again: the failed run may already have patched the files (ProxmoxVE #18060).
local redo=""
if [[ -f "${version_file}.pending" ]]; then
redo=1
else
printf '%s' "$CS_PREVIOUS_VERSION" >"${version_file}.pending" 2>/dev/null || true
fi
_CS_DEPLOYED=1

local current_version=""
[[ -f "$version_file" ]] && current_version="$(<"$version_file")"
if [[ "$current_version" == "$version" && -d "$target" && "${FORCE_UPDATE:-}" != "1" ]]; then
if [[ -z "$redo" && "$current_version" == "$version" && -d "$target" && "${FORCE_UPDATE:-}" != "1" ]]; then
msg_ok "${app} ${version} already installed"
return 0
fi
Expand Down
19 changes: 19 additions & 0 deletions tests/release-stamp-pending.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ expect "without a marker it is the stamp" 2.16.0 "$CS_PREVIOUS_VERSION"
rm -f "$HOME/.npm"
expect "a fresh install has no previous version" "" "$(_forge_previous_version "$HOME/.npm")"

# fetch_and_deploy_release: a redo deploys again, the failed run may have patched the files
eval "$(awk '/^fetch_and_deploy_release[(][)] [{]/,/^}/' "$CORE_DIR/lib/forge.func")"
_forge_release_json() { printf '%s' '{"tag_name":"v2.16.0"}' >"$5"; }
_forge_source_url() { echo "https://example.invalid/src.tar.gz"; }
_download_source_tarball() { :; }
_deploy_source_tarball() { echo "deploy" >>"$LOG"; }
deploy() {
: >"$LOG"
rm -f "$HOME/.npm.pending"
echo 2.16.0 >"$HOME/.npm"
mkdir -p "$TEST_DIR/target"
[[ "$1" == "yes" ]] && printf '%s' 2.15.1 >"$HOME/.npm.pending"
fetch_and_deploy_release github NPM owner/repo tarball latest "$TEST_DIR/target" >/dev/null 2>&1
grep -c '^deploy$' "$LOG"
}
expect "current stamp, no marker: already installed" 0 "$(deploy no)"
expect "current stamp, marker: deployed again" 1 "$(deploy yes)"
rm -f "$HOME/.npm" "$HOME/.npm.pending"

# on_exit: only a run that deployed and exits 0 removes the marker
touch "$HOME/.npm.pending"
(_CS_DEPLOYED=1; on_exit) 2>/dev/null
Expand Down
Loading