From 11d263a2bffa64f84380685a688e995dae34f563 Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Wed, 14 Jan 2026 23:57:20 -0600 Subject: [PATCH] feat: add automatic migration dialog for legacy downloads Implement user-consent migration system for legacy numeric-named FLAC files: - Create MigrationModal component with progress tracking - Auto-detect legacy downloads on settings mount - Show modal with migration details and consent dialog - Real-time progress updates via Tauri events - Display success/failure stats after migration - Refresh library and stats after completion cc --- src/lib/components/MigrationModal.svelte | 363 +++++++++++++++++++ src/lib/components/views/SettingsView.svelte | 32 ++ 2 files changed, 395 insertions(+) create mode 100644 src/lib/components/MigrationModal.svelte diff --git a/src/lib/components/MigrationModal.svelte b/src/lib/components/MigrationModal.svelte new file mode 100644 index 000000000..cd70a279c --- /dev/null +++ b/src/lib/components/MigrationModal.svelte @@ -0,0 +1,363 @@ + + + + {#snippet children()} +
+ {#if !migrating && !progress?.completed} +
+
+ +
+

Legacy Downloads Detected

+

+ We found {totalTracks} downloads from a previous version + that need to be migrated to the new organized format. +

+

+ This process will: +

+
    +
  • Fetch complete metadata from Qobuz
  • +
  • Add proper tags to your FLAC files
  • +
  • Organize files into Artist/Album folders
  • +
  • Embed album artwork
  • +
  • Add tracks to your local library (if enabled)
  • +
+

+ Note: This may take a few minutes depending on your internet + connection and the number of downloads. The old files will be deleted after + successful migration. +

+
+ {:else if migrating || (progress && progress.in_progress)} +
+
+ +
+

Migrating Downloads...

+ {#if progress} +
+
+
+

+ {progress.processed} / {progress.total_tracks} tracks processed + ({progress.successful} successful, {progress.failed} failed) +

+ {:else} +

Starting migration...

+ {/if} +
+ {:else if progress?.completed} +
+
+ +
+

Migration Complete

+
+
+ + {progress.successful} successful +
+ {#if progress.failed > 0} +
+ + {progress.failed} failed +
+ {/if} +
+ {#if progress.errors.length > 0} +
+ View errors ({progress.errors.length}) +
+ {#each progress.errors as error} +
+ Track {error.track_id}: {error.error_message} +
+ {/each} +
+
+ {/if} +

+ Your downloads have been organized and are now available in your local library. +

+
+ {/if} +
+ {/snippet} + + {#snippet footer()} + + {/snippet} +
+ + diff --git a/src/lib/components/views/SettingsView.svelte b/src/lib/components/views/SettingsView.svelte index ce9488d6b..72943088e 100644 --- a/src/lib/components/views/SettingsView.svelte +++ b/src/lib/components/views/SettingsView.svelte @@ -27,6 +27,7 @@ } from '$lib/services/playbackService'; import { setLocale, locale, t } from '$lib/i18n'; import { get } from 'svelte/store'; + import MigrationModal from '../MigrationModal.svelte'; interface Props { onBack?: () => void; @@ -68,6 +69,10 @@ // Lyrics cache state let isClearingLyrics = $state(false); + // Migration state + let showMigrationModal = $state(false); + let legacyTracksCount = $state(0); + // Audio device state let audioDevices = $state([]); let pipewireSinks = $state([]); @@ -257,6 +262,9 @@ toastsEnabled = getToastsEnabled(); loadSystemNotificationsPreference(); systemNotificationsEnabled = getSystemNotificationsEnabled(); + + // Check for legacy downloads + checkLegacyDownloads(); }); async function loadLastfmState() { @@ -680,6 +688,24 @@ } } + async function checkLegacyDownloads() { + try { + const result = await invoke<{has_legacy_files: boolean, total_tracks: number}>('detect_legacy_downloads'); + if (result.has_legacy_files && result.total_tracks > 0) { + legacyTracksCount = result.total_tracks; + showMigrationModal = true; + } + } catch (err) { + console.error('Failed to check for legacy downloads:', err); + } + } + + function closeMigrationModal() { + showMigrationModal = false; + // Refresh stats after migration + loadDownloadStats(); + } + async function handleChangeDownloadFolder() { try { const { open } = await import('@tauri-apps/plugin-dialog'); @@ -1896,3 +1922,9 @@ cursor: not-allowed; } + +