agent: code-atomiser-fix — migrate Tauri app_data_dir on bundle-identifier change
Commit14313cfchanged the Tauri bundle identifier from uk.co.corbel.magnotia to consulting.corbel.lumotia. Tauri 2 keys both app_data_dir and the webview's data store (localStorage, IndexedDB, cookies, service worker, cache) plus all Tauri-plugin state files (window-state geometry, autostart enable flag) by the identifier. Without an explicit migration, every user's webview state was silently orphaned on first launch under the new identifier; the JS-side migrateLocalStorageKey helper introduced in1608109ran against an empty store and no-op'd. Fix: in the Tauri setup hook, before webview navigation, resolve the legacy app_data_dir under the OLD bundle identifier and recursively copy it to the new identifier's app_data_dir via an atomic staging rename. Idempotent: legacy preserved as a backup; if both paths exist post-rename, a warning is logged and the new path is used unchanged. Regression tests cover the migrate-only, both-exist, no-legacy, and idempotent (run twice) cases against synthetic legacy/new paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -471,7 +471,12 @@ fn is_cross_device(err: &std::io::Error) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), std::io::Error> {
|
||||
/// Symlink-aware recursive directory copy used by the legacy data-dir
|
||||
/// migration and by the Tauri-side `app_data_dir` bundle-identifier
|
||||
/// migration in `src-tauri/src/tauri_app_data_migration.rs`. Exposed as
|
||||
/// `pub` so callers in sibling crates can reuse the same hardened
|
||||
/// implementation (see commit history for the symlink-loop defence).
|
||||
pub fn copy_dir_recursive(from: &Path, to: &Path) -> Result<(), std::io::Error> {
|
||||
std::fs::create_dir_all(to)?;
|
||||
for entry in std::fs::read_dir(from)? {
|
||||
let entry = entry?;
|
||||
|
||||
Reference in New Issue
Block a user