feat: auto-use cached HQ video file without upgrade prompt

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-22 14:36:33 -04:00
parent 90f598050c
commit 8bd2b34103

View File

@@ -262,6 +262,22 @@ export async function beginDownload() {
session.processingStep = 'downloading'; session.processingStep = 'downloading';
// --- Check export (HQ) cache first ---
const exportCached = await checkCachedDownload(session.title, 'export').catch(() => null);
if (exportCached) {
// HQ file already on disk — use it directly, skip preview entirely
session.exportFilePath = exportCached;
session.exportProgress = 1.0;
session.exportStatus = 'complete';
session.previewFilePath = exportCached;
session.previewProgress = 1.0;
session.previewStatus = 'complete';
session.activeVideoPath = exportCached;
// No upgrade toast — we're already at best quality
triggerPostDownloadProcessing(exportCached);
return;
}
// --- Preview download (low-res, fast) --- // --- Preview download (low-res, fast) ---
const previewCached = await checkCachedDownload(session.title, 'preview').catch(() => null); const previewCached = await checkCachedDownload(session.title, 'preview').catch(() => null);
if (previewCached) { if (previewCached) {
@@ -305,45 +321,35 @@ export async function beginDownload() {
} }
// --- Export download (best quality, background) --- // --- Export download (best quality, background) ---
const exportCached = await checkCachedDownload(session.title, 'export').catch(() => null); // Only start if not already cached (we handled cached case above with early return)
if (exportCached) { session.exportStatus = 'downloading';
session.exportFilePath = exportCached; session.exportProgress = 0;
session.exportProgress = 1.0; session.exportFilePath = null;
session.exportStatus = 'complete';
if ((session.processingStep as ProcessingStep) === 'done') {
session.showUpgradeToast = true;
}
} else {
session.exportStatus = 'downloading';
session.exportProgress = 0;
session.exportFilePath = null;
// Fire-and-forget — runs in background runDownload(
runDownload( session.url,
session.url, EXPORT_FORMAT,
EXPORT_FORMAT, 'export',
'export', (pct) => { session.exportProgress = pct; },
(pct) => { session.exportProgress = pct; }, (path) => { session.exportFilePath = path; },
(path) => { session.exportFilePath = path; }, (success, path) => {
(success, path) => { if (success) {
if (success) { session.exportProgress = 1.0;
session.exportProgress = 1.0; session.exportFilePath = path;
session.exportFilePath = path; session.exportStatus = 'complete';
session.exportStatus = 'complete'; if ((session.processingStep as ProcessingStep) === 'done') {
if ((session.processingStep as ProcessingStep) === 'done') { session.showUpgradeToast = true;
session.showUpgradeToast = true;
}
} else {
session.exportStatus = 'failed';
} }
}, } else {
(message) => {
session.exportStatus = 'failed'; session.exportStatus = 'failed';
console.error('Export download error:', message);
} }
).catch((e) => { },
(message) => {
session.exportStatus = 'failed'; session.exportStatus = 'failed';
console.error('Export download failed:', e); console.error('Export download error:', message);
}); }
} ).catch((e) => {
session.exportStatus = 'failed';
console.error('Export download failed:', e);
});
} }