mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-15 03:37:03 -04:00
* Single instance: enable tab handoff in Windows portable mode (#889) * Single instance: a portable copy's socket stays in %LOCALAPPDATA%, under its own name (cherry picked from commit c7db1e80a374e80a11504efefbaac680dfa5e872) --------- Co-authored-by: Brandon Thomas <[email protected]>
This commit is contained in:
1 parent
2a909f361c
commit
b21045de6e
1 file changed
+7
-8
@@ -135,17 +135,16 @@ pub fn claim(files: &[String], may_hand_off: bool) -> Claim {
|
||||
}
|
||||
}
|
||||
|
||||
/// The socket in `%LOCALAPPDATA%\PdfCraft` (beside the crash-recovery folder); none for a portable
|
||||
/// copy.
|
||||
/// The socket in `%LOCALAPPDATA%\PdfCraft` (beside the crash-recovery folder); none when
|
||||
/// `%LOCALAPPDATA%` is unset.
|
||||
#[cfg(windows)]
|
||||
fn socket_path() -> Option<std::path::PathBuf> {
|
||||
let name = socket_name(std::env::var("SESSIONNAME").ok().as_deref());
|
||||
// A portable copy may sit in a folder other accounts can write to (`C:\Tools`): a socket
|
||||
// there would let them receive this user's file paths or send it files to open. Portable
|
||||
// launches each open their own window instead, and write nothing outside their folder.
|
||||
if pdfcraft_ui_egui::portable::data_dir().is_some() {
|
||||
return None;
|
||||
}
|
||||
// %LOCALAPPDATA% is private to the user's sign-in, so other accounts can't receive this
|
||||
// user's file paths or send it files to open. A portable copy uses it too (#889), under its
|
||||
// own name so it never hands files to an installed copy (which keeps its settings elsewhere).
|
||||
// Never the portable folder itself: it may sit where other accounts can write (`C:\Tools`).
|
||||
let name = if pdfcraft_ui_egui::portable::data_dir().is_some() { format!("portable-{name}") } else { name };
|
||||
std::env::var_os("LOCALAPPDATA").filter(|v| !v.is_empty()).map(|d| std::path::PathBuf::from(d).join("PdfCraft").join(name))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user