Add Repair Downloads button in Settings UI
Added UI for library_backfill_downloads command in Settings > Downloads section. Features: - "Repair Downloads" button with description - Shows repair report with counts (added/repaired/skipped/failed) - Triggers library reload after repair to reflect changes - Disabled when no downloads exist or repair is in progress Location: Between "Show in Local Library" toggle and "Clear Downloads" button This allows users to easily restore source markers for Qobuz downloads that were damaged during library scans. Files changed: - src/lib/components/views/SettingsView.svelte
This commit is contained in:
1 parent
ac77a31b06
commit
fb1dfa05a4
1 file changed
+40
@@ -89,6 +89,7 @@
|
|||||||
// Download cache state (offline storage)
|
// Download cache state (offline storage)
|
||||||
let downloadStats = $state<DownloadCacheStats | null>(null);
|
let downloadStats = $state<DownloadCacheStats | null>(null);
|
||||||
let isClearingDownloads = $state(false);
|
let isClearingDownloads = $state(false);
|
||||||
|
let isRepairingDownloads = $state(false);
|
||||||
|
|
||||||
// Lyrics cache state
|
// Lyrics cache state
|
||||||
let isClearingLyrics = $state(false);
|
let isClearingLyrics = $state(false);
|
||||||
@@ -1291,6 +1292,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleRepairDownloads() {
|
||||||
|
if (isRepairingDownloads) return;
|
||||||
|
isRepairingDownloads = true;
|
||||||
|
try {
|
||||||
|
const report = await invoke<{
|
||||||
|
total_downloads: number;
|
||||||
|
added_tracks: number;
|
||||||
|
repaired_tracks: number;
|
||||||
|
skipped_tracks: number;
|
||||||
|
failed_tracks: string[];
|
||||||
|
}>('library_backfill_downloads');
|
||||||
|
|
||||||
|
const message = `Repair complete!\n\nAdded: ${report.added_tracks}\nRepaired: ${report.repaired_tracks}\nSkipped: ${report.skipped_tracks}\nFailed: ${report.failed_tracks.length}`;
|
||||||
|
|
||||||
|
showToast(message, 'success');
|
||||||
|
|
||||||
|
// Trigger library reload
|
||||||
|
notifyDownloadSettingsChanged();
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Failed to repair downloads:', err);
|
||||||
|
showToast('Failed to repair downloads: ' + String(err), 'error');
|
||||||
|
} finally {
|
||||||
|
isRepairingDownloads = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function handleClearDownloads() {
|
async function handleClearDownloads() {
|
||||||
if (isClearingDownloads) return;
|
if (isClearingDownloads) return;
|
||||||
isClearingDownloads = true;
|
isClearingDownloads = true;
|
||||||
@@ -1726,6 +1753,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<Toggle enabled={showQobuzDownloadsInLibrary} onchange={handleShowDownloadsChange} />
|
<Toggle enabled={showQobuzDownloadsInLibrary} onchange={handleShowDownloadsChange} />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-row">
|
||||||
|
<div class="setting-with-description">
|
||||||
|
<span class="setting-label">Repair Downloads</span>
|
||||||
|
<span class="setting-description">Fix download markers lost during library scans</span>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
class="clear-btn"
|
||||||
|
onclick={handleRepairDownloads}
|
||||||
|
disabled={isRepairingDownloads || !downloadStats || downloadStats.readyTracks === 0}
|
||||||
|
>
|
||||||
|
{isRepairingDownloads ? 'Repairing...' : 'Repair'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="setting-row">
|
<div class="setting-row">
|
||||||
<span class="setting-label">Clear Downloads</span>
|
<span class="setting-label">Clear Downloads</span>
|
||||||
<button
|
<button
|
||||||
|
|||||||
Reference in new issue
Block a user