Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Windows: folder moves hold through a scanner, tests in each system's own paths
Yashwanth Kamireddid4b1f4c4b16c
diff --git a/.uiverify/footer-refresh.mjs b/.uiverify/footer-refresh.mjsindex 3f4a103..43f0971 100644--- a/.uiverify/footer-refresh.mjs+++ b/.uiverify/footer-refresh.mjs@@ -72,7 +72,7 @@ ok(reloaded === 0, "neither key reloads the window");await page.evaluate(() => { window.__someFail = "Apple didn’t answer."; });await status.click();await page.waitForTimeout(800);-ok((await said()) === "iCloud Drive didn’t update: Apple didn’t answer." && (await status.getAttribute("class")).includes("is-trouble"), `a failure says why [${await said()}]`);+ok((await said()) === "Drive didn’t update: Apple didn’t answer." && (await status.getAttribute("class")).includes("is-trouble"), `a failure says why [${await said()}]`);await page.locator(".sidebar-account").click();await page.waitForSelector(".settings");diff --git a/.uiverify/photos-scale.mjs b/.uiverify/photos-scale.mjsindex 3c1a8ac..5060547 100644--- a/.uiverify/photos-scale.mjs+++ b/.uiverify/photos-scale.mjs@@ -28,7 +28,9 @@ const sizes = await page.evaluate(async () => {const later = months.find((s) => s.querySelector(".px-later"));const before = later.getBoundingClientRect().height;later.scrollIntoView();- await new Promise((r) => setTimeout(r, 400));+ // Built a few rows a frame: waited for, up to three seconds, not a fixed moment (a slower+ // machine finished it later than 400ms).+ for (let t = 0; t < 30 && later.querySelector(".px-later"); t++) await new Promise((r) => setTimeout(r, 100));return { before, after: later.getBoundingClientRect().height, built: !later.querySelector(".px-later") };});ok(sizes.built && Math.abs(sizes.before - sizes.after) < 1,@@ -43,7 +45,9 @@ const fitted = await page.evaluate(async () => {const later = months.find((s) => s.querySelector(".px-later"));const before = later.getBoundingClientRect().height;later.scrollIntoView();- await new Promise((r) => setTimeout(r, 400));+ // Built a few rows a frame: waited for, up to three seconds, not a fixed moment (a slower+ // machine finished it later than 400ms).+ for (let t = 0; t < 30 && later.querySelector(".px-later"); t++) await new Promise((r) => setTimeout(r, 100));return { before, after: later.getBoundingClientRect().height, built: !later.querySelector(".px-later") };});ok(fitted.built && Math.abs(fitted.before - fitted.after) < 1,diff --git a/src-tauri/src/apps.rs b/src-tauri/src/apps.rsindex 945e8b3..514b397 100644--- a/src-tauri/src/apps.rs+++ b/src-tauri/src/apps.rs@@ -313,6 +313,33 @@ mod tests {assert_eq!(new_asked(&args(&["skykeep", "--app", "notes"])), None);}+ /// Windows paths and links, as Explorer and a browser hand them over.+ #[cfg(windows)]+ #[test]+ fn opened_files_are_taken_as_windows_paths_or_uris() {+ let cwd = std::path::Path::new(r"C:\Users\a\Downloads");+ let got = files_asked(+ &args(&[+ "skykeep",+ "invite.ics",+ r"C:\Temp\Card.VCF",+ "file:///C:/Users/a/My%20Events.ics",+ "notes.txt",+ ]),+ cwd,+ );+ assert_eq!(+ got,+ vec![+ std::path::PathBuf::from(r"C:\Users\a\Downloads\invite.ics"),+ std::path::PathBuf::from(r"C:\Temp\Card.VCF"),+ std::path::PathBuf::from("C:/Users/a/My Events.ics"),+ ]+ );+ }++ /// Linux paths and links, as a file manager hands them over.+ #[cfg(not(windows))]#[test]fn opened_files_are_taken_as_paths_or_uris() {let cwd = std::path::Path::new("/home/a/Downloads");diff --git a/src-tauri/src/migrate.rs b/src-tauri/src/migrate.rsindex ab195b9..7b6b8f2 100644--- a/src-tauri/src/migrate.rs+++ b/src-tauri/src/migrate.rs@@ -352,7 +352,7 @@ fn move_dir((mover.checkpoint)(Step::Marked)?;}if !mover.across {- match fs::rename(old, new) {+ match rename(old, new) {Ok(()) => {sync_dir(parent);return (mover.checkpoint)(Step::Renamed);@@ -384,7 +384,7 @@ fn finish_copy(parent: &Path, ids: Ids<'_>, mover: &Mover) -> io::Result<()> {"the new folder appeared while the copy was in progress",));}- fs::rename(&staging, new)?;+ rename(&staging, new)?;sync_dir(parent);}(mover.checkpoint)(Step::InPlace)?;@@ -416,7 +416,7 @@ fn merge(old: &Path, new: &Path) -> io::Result<()> {if present(&to) {continue;}- match fs::rename(entry.path(), &to) {+ match rename(&entry.path(), &to) {Ok(()) => {}Err(e) if crosses_devices(&e) => {quiet!("quince: identifier: left in the old folder: {e}");@@ -450,7 +450,7 @@ fn autostart(dir: &Path, ids: Ids<'_>) -> io::Result<()> {}let part = dir.join(format!(".{}.desktop.part", ids.new));write_synced(&part, moved.as_bytes())?;- fs::rename(&part, &new)?;+ rename(&part, &new)?;sync_dir(dir);}fs::remove_file(&old)@@ -612,7 +612,7 @@ fn set_aside(dir: &Path) -> io::Result<()> {dir.display(),to.display());- fs::rename(dir, &to)+ rename(dir, &to)}fn write_marker(dir: &Path, ids: Ids<'_>) -> io::Result<()> {@@ -635,6 +635,32 @@ fn holds_marker(dir: &Path) -> bool {})}+/// `fs::rename`, made to hold on Windows: a file just written may be held for a moment by the+/// virus scanner or the search indexer (ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION), and+/// Windows will not rename over an existing empty folder as Linux does. Both are tried again+/// for up to two seconds; anything else is said at once.+fn rename(from: &Path, to: &Path) -> io::Result<()> {+ #[cfg(windows)]+ {+ let mut tries = 0;+ loop {+ match fs::rename(from, to) {+ Ok(()) => return Ok(()),+ Err(e) if matches!(e.raw_os_error(), Some(5 | 32)) && tries < 40 => {+ if to.is_dir() && fs::read_dir(to).is_ok_and(|mut d| d.next().is_none()) {+ let _ = fs::remove_dir(to);+ }+ tries += 1;+ std::thread::sleep(std::time::Duration::from_millis(50));+ }+ Err(e) => return Err(e),+ }+ }+ }+ #[cfg(not(windows))]+ fs::rename(from, to)+}+fn write_synced(path: &Path, bytes: &[u8]) -> io::Result<()> {use io::Write;let mut f = fs::File::create(path)?;@@ -935,12 +961,21 @@ mod tests {fn install(h: &Home) {let old = h.old();{- let mut library = quince_core::Library::open(&old).unwrap();+ // Ended as a crash ends it: no checkpoint, so the row lives in the WAL alone. Made+ // beside the folder and copied in, so this process holds nothing open inside it — a+ // crashed app holds nothing, and Windows will not rename a folder with a file open.+ let crashed = h.roots.primary.parent().unwrap().join("crashed-library");+ let mut library = quince_core::Library::open(&crashed).unwrap();library.set_state("remembered", "kept-through-the-move").unwrap();- // Ended as a crash ends it: no checkpoint, so the row lives in the WAL alone.std::mem::forget(library);+ fs::create_dir_all(&old).unwrap();+ for f in ["library.db", "library.db-wal", "library.db-shm"] {+ if crashed.join(f).exists() {+ fs::copy(crashed.join(f), old.join(f)).unwrap();+ }+ }}assert!(fs::metadata(old.join("library.db-wal")).unwrap().len() > 0,