fix: clear thumbnail cache and temp dirs on new session

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 11:18:14 -04:00
parent ab053edd14
commit 8013ef7c55
6 changed files with 39 additions and 0 deletions

View File

@@ -2,10 +2,12 @@ import type { VideoMetadata } from '$lib/bindings/video';
import { startDownload } from '$lib/bindings/video';
import type { ThumbnailSpritesheet } from '$lib/bindings/mediaAnalysis';
import {
cleanupThumbnails,
extractKeyframes,
extractThumbnails,
extractWaveform,
} from '$lib/bindings/mediaAnalysis';
import { clearThumbnailCache } from '$lib/timeline/thumbnailRenderer';
export type SessionStatus = 'idle' | 'resolving' | 'ready' | 'error';
export type DownloadStatus = 'idle' | 'downloading' | 'complete' | 'failed';
@@ -112,6 +114,10 @@ async function triggerPostDownloadProcessing(filePath: string) {
export async function beginDownload() {
if (!session.url) return;
const oldThumbnailDirs = [
...new Set(session.thumbnailSpritesheets.map((sheet) => sheet.filePath)),
];
clearThumbnailCache();
session.downloadStatus = 'downloading';
session.downloadProgress = 0;
session.localFilePath = null;
@@ -119,6 +125,12 @@ export async function beginDownload() {
session.waveformPeaks = [];
session.thumbnailSpritesheets = [];
if (oldThumbnailDirs.length > 0) {
void cleanupThumbnails(oldThumbnailDirs).catch((err) => {
console.error('Thumbnail temp dir cleanup failed:', err);
});
}
try {
await startDownload(
session.url,