Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.
fix(core): received files carry the Mark of the Web on Windows
Beee69787e7a635
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ccd216c..95239e2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -143,6 +143,9 @@ has a Stop button. Choosing another### Changed+- **Files received on Windows are marked as from another device,** the way+ a browser marks a download, so Windows checks a program with SmartScreen+ before it runs and Office opens documents in Protected View.- **Pause for banking apps uses less battery.** While the screen is off,the phone checks the app in front every 15 seconds instead of severaltimes a second, and checks again as soon as the screen turns on. Bydiff --git a/core/nectarlink-core/src/continuity_camera.rs b/core/nectarlink-core/src/continuity_camera.rsindex afdc517..375469e 100644--- a/core/nectarlink-core/src/continuity_camera.rs+++ b/core/nectarlink-core/src/continuity_camera.rs@@ -347,7 +347,10 @@ async fn take_result(Ok(()) => {let dest = crate::transfer::unique_path(&shared.downloads_dir, &safe_name);match tokio::fs::write(&dest, &data).await {- Ok(()) => Some(dest),+ Ok(()) => {+ crate::transfer::mark_from_elsewhere(&dest);+ Some(dest)+ }Err(e) => {tracing::warn!(error = %e, "can't save continuity camera capture");Nonediff --git a/core/nectarlink-core/src/localsend.rs b/core/nectarlink-core/src/localsend.rsindex b7f72a2..cc85027 100644--- a/core/nectarlink-core/src/localsend.rs+++ b/core/nectarlink-core/src/localsend.rs@@ -1348,6 +1348,7 @@ async fn finalize_uploaded_file(fs::copy(&part_path, &dest)?;let _ = fs::remove_file(&part_path);}+ crate::transfer::mark_from_elsewhere(&dest);if folder.is_none() {guard.saved_items.push(dest);}diff --git a/core/nectarlink-core/src/transfer.rs b/core/nectarlink-core/src/transfer.rsindex 1b8e33c..ad1ab8d 100644--- a/core/nectarlink-core/src/transfer.rs+++ b/core/nectarlink-core/src/transfer.rs@@ -1978,6 +1978,7 @@ fn save_files(target: &Path, entries: &[FileEntry], parts: Vec<PathBuf>) -> std:};let to = unique_path(&at, &storable_name(&entry.name));move_file(&part, &to)?;+ mark_from_elsewhere(&to);moved.push((to.clone(), part));if entry.folder.is_none() {saved.push(to);@@ -2000,6 +2001,24 @@ fn save_files(target: &Path, entries: &[FileEntry], parts: Vec<PathBuf>) -> std:Ok(saved)}+/// Marks a received file as coming from another device, the way a browser+/// marks a download: on Windows that's the Internet zone (Mark of the Web),+/// so SmartScreen checks a program before it runs and Office opens a+/// document in Protected View. Best effort: a drive without alternate data+/// streams (FAT32, say) takes no mark.+pub(crate) fn mark_from_elsewhere(path: &Path) {+ #[cfg(windows)]+ {+ let mut stream = path.as_os_str().to_owned();+ stream.push(":Zone.Identifier");+ if let Err(e) = std::fs::write(&stream, "[ZoneTransfer]\r\nZoneId=3\r\n") {+ tracing::debug!(error = %e, "can't mark a received file as from elsewhere");+ }+ }+ #[cfg(not(windows))]+ let _ = path;+}+/// Moves `from` to `to`, copying when they're on different volumes.fn move_file(from: &Path, to: &Path) -> std::io::Result<()> {if std::fs::rename(from, to).is_err() {@@ -2059,6 +2078,18 @@ pub(crate) fn clean_incoming(dir: &Path) {mod tests {use super::*;+ #[cfg(windows)]+ #[test]+ fn received_files_are_marked_as_from_the_internet_zone() {+ let dir = tempfile::tempdir().unwrap();+ let file = dir.path().join("setup.exe");+ std::fs::write(&file, b"MZ").unwrap();+ mark_from_elsewhere(&file);+ let mut stream = file.into_os_string();+ stream.push(":Zone.Identifier");+ assert_eq!(std::fs::read_to_string(stream).unwrap(), "[ZoneTransfer]\r\nZoneId=3\r\n");+ }+#[test]fn files_go_back_to_their_part_files_when_one_cant_be_saved() {let dir = tempfile::tempdir().unwrap();