Skip to content

Commit 1da0a44

Browse files
program247365claude
andcommitted
fix(storage): migrate history from legacy iCloud path on upgrade
Users upgrading from v0.5.4 had their history silently dropped because the iCloud auto-detection was removed without a migration path. On first launch, the local DB was empty while the old iCloud DB still had all their data. On macOS, when no sync replica is configured, open_and_migrate() now checks the old iCloud auto-detected path and pulls from it if it has newer data than the local DB. Uses the same try_pull_from_replica path so the copy is atomic and idempotent. Bump version to v0.5.6 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ba3fc42 commit 1da0a44

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "looper"
3-
version = "0.5.5"
3+
version = "0.5.6"
44
authors = ["Kevin B. Ridgway <kridgway@gmail.com>"]
55
edition = "2018"
66

src/storage.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,16 @@ impl Storage {
159159
reason: err.to_string(),
160160
}),
161161
},
162-
None => None,
162+
None => {
163+
// One-time legacy migration for users upgrading from v0.5.4 and earlier:
164+
// their history lives in the old iCloud auto-detected path. Pull silently
165+
// if that path exists and the local DB has no newer data.
166+
#[cfg(target_os = "macos")]
167+
if let Some(legacy) = legacy_icloud_db_path() {
168+
let _ = try_pull_from_replica(&legacy, &local_path);
169+
}
170+
None
171+
}
163172
};
164173

165174
let storage = Self::open_and_migrate_at(local_path)?;
@@ -467,6 +476,13 @@ fn checkpoint_db(path: &Path) -> Result<()> {
467476
Ok(())
468477
}
469478

479+
#[cfg(target_os = "macos")]
480+
fn legacy_icloud_db_path() -> Option<PathBuf> {
481+
let home = directories::UserDirs::new()?.home_dir().to_path_buf();
482+
let path = home.join("Library/Mobile Documents/com~apple~CloudDocs/looper/looper.sqlite3");
483+
if path.exists() { Some(path) } else { None }
484+
}
485+
470486
fn sync_folder_config_path() -> Option<PathBuf> {
471487
directories::BaseDirs::new()
472488
.map(|b| b.home_dir().join(".config").join("looper").join("sync_folder"))

0 commit comments

Comments
 (0)