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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- **The Windows in-app uninstall now fully removes the data root.** When you unchecked "keep my settings & logs", the uninstall could leave `%ProgramData%\WsScrcpyWeb` behind. The helper that does the cleanup ran from *inside* that folder (`…\control\operation-server\`), and Windows can't delete a running program — and even after a successful delete, the helper's own logging immediately recreated the `logs` folder. The helper now copies itself to the system temp folder and that copy — with logging turned off, and after waiting for the original to exit — runs the uninstaller and deletes the data root, so nothing is left behind. Keeping settings still preserves `config.json` and `logs`.

## [0.1.30-beta.51] - 2026-06-08

### Added
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ windows = { version = "0.58", features = [
"Win32_Foundation",
"Win32_Graphics_Gdi",
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_Console",
"Win32_System_Environment",
"Win32_System_JobObjects",
Expand Down
30 changes: 30 additions & 0 deletions common/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,26 @@
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::PathBuf;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::OnceLock;
use std::time::{SystemTime, UNIX_EPOCH};

static LOG_NAME: OnceLock<String> = OnceLock::new();
static LOG_DISABLED: AtomicBool = AtomicBool::new(false);

/// Turn off all logging (file + stderr) for this process. Used by the
/// Windows in-app uninstall cleaner: every `append()` calls
/// `create_dir_all(<dataRoot>/logs)`, which would resurrect the data root
/// after a `--wipe`. The cleaner calls this once at startup so deletion is
/// final. Idempotent; intentionally no re-enable.
pub fn disable() {
LOG_DISABLED.store(true, Ordering::Relaxed);
}

/// True once `disable()` has been called in this process.
pub fn is_disabled() -> bool {
LOG_DISABLED.load(Ordering::Relaxed)
}

/// Set the log file basename for this process. Should be called once
/// at startup, before any [`info`]/[`error`] calls, with the binary's
Expand Down Expand Up @@ -107,6 +123,9 @@ fn civil_from_days(z: i64) -> (i32, u32, u32) {
}

fn append(prefix: &str, msg: &str) {
if is_disabled() {
return;
}
let ts = format_timestamp_utc(SystemTime::now());
if let Some(path) = log_path() {
if let Ok(mut f) = OpenOptions::new().create(true).append(true).open(&path) {
Expand Down Expand Up @@ -169,4 +188,15 @@ mod tests {
// common test process never calls init() so this is safe.
assert_eq!(log_basename(), "launcher");
}

#[test]
fn disable_silences_logging() {
// The Windows uninstall cleaner must be able to turn off all logging so
// that append()'s create_dir_all(<dataRoot>/logs) never resurrects the
// data root after a wipe. disable() is process-global and irreversible;
// no other common-crate test reads is_disabled(), so ordering is safe.
assert!(!is_disabled(), "logging starts enabled");
disable();
assert!(is_disabled(), "disable() must set the gate");
}
}
Loading
Loading