diff options
| author | 2026-01-18 13:43:12 +0800 | |
|---|---|---|
| committer | 2026-01-18 13:43:12 +0800 | |
| commit | 17e8dd78ca5b7aae9baa4f86d38fa755c8af21c5 (patch) | |
| tree | 1fc3c9adb05264b12ed0fa473b997bfca14716e6 /ui/src/components | |
| parent | 02520ca62ac5e508e8748b2445171be64f459b6c (diff) | |
| download | DropOut-17e8dd78ca5b7aae9baa4f86d38fa755c8af21c5.tar.gz DropOut-17e8dd78ca5b7aae9baa4f86d38fa755c8af21c5.zip | |
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
Diffstat (limited to 'ui/src/components')
| -rw-r--r-- | ui/src/components/SettingsView.svelte | 31 |
1 files changed, 28 insertions, 3 deletions
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; } } </script> @@ -444,7 +463,13 @@ <h4 class="text-sm font-medium text-white/90">Run Migration</h4> <p class="text-xs text-white/40 mt-1">Hard-link or copy existing per-instance caches into the shared cache.</p> </div> - <button onclick={runMigrationToSharedCaches} class="px-4 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white text-sm">Migrate Now</button> + <button + onclick={runMigrationToSharedCaches} + disabled={migrating} + class="px-4 py-2 rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white text-sm disabled:opacity-50 disabled:cursor-not-allowed" + > + {migrating ? "Migrating..." : "Migrate Now"} + </button> </div> </div> </div> |