style: wrap portable update signatures and documentation

This commit is contained in:
skylartaylor committed 2026-10-22 15:59:32 +02:00
1 parent b9b24da3d2
commit 123032ea07
1 file changed
+17 -3
+17 -3
View File
@@ -307,10 +307,17 @@ pub fn remove(app: &CraftApp, record: &Record) -> Result<(), String> {
/// Unpacks the launcher's own portable zip into `staging`, with the same checks as an app's, and
/// copies it over `folder` for a self-update. `check` must accept every unpacked file before
/// any is copied, and again before the backup is removed. The archive must include `executable`.
/// When every file sits in one top-level folder, that folder's contents are the program. A copy that fails puts the previous files back. When one of them can't be put back,
/// When every file sits in one top-level folder, that folder's contents are the program. A copy
/// that fails puts the previous files back. When one of them can't be put back,
/// the previous files move to a `<staging>-recovery-<time>` folder beside `staging`, which no
/// later update removes, and the error names it. `staging` is removed afterwards.
pub fn unpack_over(zip: &Path, staging: &Path, folder: &Path, executable: &std::ffi::OsStr, check: &dyn Fn(&Path) -> Result<(), String>) -> Result<(), String> {
pub fn unpack_over(
zip: &Path,
staging: &Path,
folder: &Path,
executable: &std::ffi::OsStr,
check: &dyn Fn(&Path) -> Result<(), String>,
) -> Result<(), String> {
let backup = staging.join("backup");
// A failed update whose files couldn't be moved to a recovery folder: never clear them.
if backup.exists() {
@@ -325,7 +332,14 @@ pub fn unpack_over(zip: &Path, staging: &Path, folder: &Path, executable: &std::
result
}
fn replace_with(zip: &Path, staging: &Path, folder: &Path, executable: &std::ffi::OsStr, check: &dyn Fn(&Path) -> Result<(), String>, keep: &mut bool) -> Result<(), String> {
fn replace_with(
zip: &Path,
staging: &Path,
folder: &Path,
executable: &std::ffi::OsStr,
check: &dyn Fn(&Path) -> Result<(), String>,
keep: &mut bool,
) -> Result<(), String> {
let unpacked = staging.join("unpacked");
let backup = staging.join("backup");
std::fs::create_dir_all(&unpacked).map_err(|e| e.to_string())?;