From 17e8dd78ca5b7aae9baa4f86d38fa755c8af21c5 Mon Sep 17 00:00:00 2001
From: HsiangNianian
Date: Sun, 18 Jan 2026 13:43:12 +0800
Subject: feat(migration): implement shared cache migration with SHA1 dedup
- Add migrate_to_shared_caches() with hard link preference
- SHA1-based deduplication across all instances
- Copy fallback for cross-filesystem scenarios
- Auto-enable use_shared_caches after successful migration
- UI shows statistics: moved files, hardlinks/copies, MB saved
---
ui/src/components/SettingsView.svelte | 31 ++++++++++++++++++++++++++++---
1 file changed, 28 insertions(+), 3 deletions(-)
(limited to 'ui/src/components')
diff --git a/ui/src/components/SettingsView.svelte b/ui/src/components/SettingsView.svelte
index 0e89e25..0020506 100644
--- a/ui/src/components/SettingsView.svelte
+++ b/ui/src/components/SettingsView.svelte
@@ -124,12 +124,31 @@
settingsState.saveSettings();
}
+ let migrating = $state(false);
async function runMigrationToSharedCaches() {
+ if (migrating) return;
+ migrating = true;
try {
- await (await import("@tauri-apps/api/core")).invoke("migrate_shared_caches");
- settingsState.loadSettings();
+ const { invoke } = await import("@tauri-apps/api/core");
+ const result = await invoke<{
+ moved_files: number;
+ hardlinks: number;
+ copies: number;
+ saved_mb: number;
+ }>("migrate_shared_caches");
+
+ // Reload settings to reflect changes
+ await settingsState.loadSettings();
+
+ // Show success message
+ const msg = `Migration complete! ${result.moved_files} files (${result.hardlinks} hardlinks, ${result.copies} copies), ${result.saved_mb.toFixed(2)} MB saved.`;
+ console.log(msg);
+ alert(msg);
} catch (e) {
console.error("Migration failed:", e);
+ alert(`Migration failed: ${e}`);
+ } finally {
+ migrating = false;
}
}
@@ -444,7 +463,13 @@
Run Migration
Hard-link or copy existing per-instance caches into the shared cache.
- + -- cgit v1.2.3-70-g09d2