install/verify: no rollback when installation fails part-way #19

Closed
opened 2026-11-06 16:36:13 +01:00 by michael · 1 comment
Owner

Problem

After signature and hashes are verified, verify.verify() copies the files one
by one into modules_dir/<module>/. If a mkdir or cp fails half way, the
module stays partially installed. Files of an older version are overwritten one
by one as well, so a failed upgrade leaves a mix of old and new files.

In install/init.lua the old module directory is removed before the package is
downloaded and verified (fs.remove_dir_recursive(dir) runs before download()
and helpers.verify.verify()). If the download or the verification fails after
that, the installed module is gone.

Scope

  • verify and unpack first, install in one step at the end:
    stage the new files in a directory next to the target (same filesystem),
    then replace the old directory by rename
  • keep the old version until the new one is fully in place
  • remove the old directory only after verification succeeded
  • decide how a failed cleanup of the staging directory is reported
    (it is a follow-up error next to the primary result)

Acceptance criteria

  • a failing copy leaves the previous version unchanged
  • a failing verification during upgrade leaves the installed module in place
  • no half-installed module directory remains after any failure
  • tests simulate a failing copy and a failing verification during upgrade
  • make test passes under Lua 5.1 and 5.4
## Problem After signature and hashes are verified, `verify.verify()` copies the files one by one into `modules_dir/<module>/`. If a `mkdir` or `cp` fails half way, the module stays partially installed. Files of an older version are overwritten one by one as well, so a failed upgrade leaves a mix of old and new files. In `install/init.lua` the old module directory is removed before the package is downloaded and verified (`fs.remove_dir_recursive(dir)` runs before `download()` and `helpers.verify.verify()`). If the download or the verification fails after that, the installed module is gone. ## Scope - verify and unpack first, install in one step at the end: stage the new files in a directory next to the target (same filesystem), then replace the old directory by rename - keep the old version until the new one is fully in place - remove the old directory only after verification succeeded - decide how a failed cleanup of the staging directory is reported (it is a follow-up error next to the primary result) ## Acceptance criteria - [ ] a failing copy leaves the previous version unchanged - [ ] a failing verification during upgrade leaves the installed module in place - [ ] no half-installed module directory remains after any failure - [ ] tests simulate a failing copy and a failing verification during upgrade - [ ] make test passes under Lua 5.1 and 5.4
Author
Owner

Done in v2.0.0: the package is verified first, then activate.lua copies the files next to the target and swaps the directories by renaming (..new and ..old). A failure leaves the previous version in place, and the leftovers of an aborted run are cleaned up or rolled back at the next run. The old directory is no longer removed before the download. Tests in test_activate.lua.

Done in v2.0.0: the package is verified first, then activate.lua copies the files next to the target and swaps the directories by renaming (.<id>.new and .<id>.old). A failure leaves the previous version in place, and the leftovers of an aborted run are cleaned up or rolled back at the next run. The old directory is no longer removed before the download. Tests in test_activate.lua.
michael 2026-11-14 20:40:59 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-module-manager#19
No description provided.