Skip to content

Preserve backend installs during failed updates#2316

Closed
gaoflow wants to merge 1 commit into
lemonade-sdk:mainfrom
gaoflow:fix-2313-preserve-backend-install-dir
Closed

Preserve backend installs during failed updates#2316
gaoflow wants to merge 1 commit into
lemonade-sdk:mainfrom
gaoflow:fix-2313-preserve-backend-install-dir

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • install backend archives into a unique sibling staging directory instead of the active install directory
  • replace the active install directory only after extraction, executable discovery, permissions, and version.txt all succeed
  • preserve/restore existing installs on activation failure, and remove Windows reparse-point backups without recursively deleting their targets

Fixes #2313.

Testing

  • git diff --check
  • pre-commit run --files src/cpp/server/backends/backend_utils.cpp src/cpp/server/server.cpp
  • clang++ -std=c++17 -fsyntax-only -I src/cpp/include -I /tmp/lemonade-syntax-include src/cpp/server/backends/backend_utils.cpp

Note: CMake/Ninja are not installed in my local environment, so I used temporary third-party headers under /tmp/lemonade-syntax-include for the syntax-only compile check.

AI assistance was used under my direction.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the backend installation flow so a failed backend update no longer wipes a previously working backend install (notably on Windows), by staging installs in a separate sibling directory and only swapping them into place after verification succeeds.

Changes:

  • Install backend archives into a unique sibling staging directory, then atomically replace the active install directory on success.
  • Preserve and restore an existing install if activation fails, and avoid recursively deleting Windows reparse-point backups (junction/symlink targets).
  • Update related server-side comments to reflect the new install/activation behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/cpp/server/backends/backend_utils.cpp Implements staged installs + activation/rollback logic and reparse-point-safe cleanup.
src/cpp/server/server.cpp Updates the *_bin hot-swap comment to match the new install semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +367 to +375
if (fs::exists(install_dir)) {
backup_dir = make_unique_install_sibling(install_dir.string(), ".backup");
fs::rename(install_dir, backup_dir, ec);
if (ec) {
throw std::runtime_error("Failed to move existing install directory '" +
install_dir.string() + "': " + ec.message());
}
backed_up_existing = true;
}
Phqen1x added a commit to Phqen1x/lemonade that referenced this pull request Jun 19, 2026
…ad of system() Fixes lemonade-sdk#2316

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kenvandine

Copy link
Copy Markdown
Member

This seems to be a duplicate of #2315

@kenvandine kenvandine closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cpp enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Severe Llama.cpp/CUDA Downloader Loop & Hardcoded Folder Deletion Issue on Windows

3 participants