offline mode fixes
This commit is contained in:
@@ -271,6 +271,21 @@ pub async fn resume_queued_downloads(
|
||||
(Arc::new(database.service()), target_dir)
|
||||
};
|
||||
|
||||
// Recover stale downloads: rows left in 'downloading' when the app was killed
|
||||
// mid-transfer are orphaned — nothing ever restarts them, so they show as
|
||||
// permanently "downloading". Reset them to 'pending' and clear the stale
|
||||
// stream_url so they get re-resolved and restarted from scratch below.
|
||||
let recover_query = Query::new(
|
||||
"UPDATE downloads SET status = 'pending', stream_url = NULL, progress = 0, \
|
||||
bytes_downloaded = 0, started_at = NULL \
|
||||
WHERE status = 'downloading'",
|
||||
);
|
||||
match db_service.execute(recover_query).await {
|
||||
Ok(n) if n > 0 => info!("[Catalog] Reset {} stale 'downloading' rows to pending", n),
|
||||
Ok(_) => {}
|
||||
Err(e) => warn!("[Catalog] Failed to reset stale downloads: {}", e),
|
||||
}
|
||||
|
||||
// Resolve each row's URL against the (now reachable) repository.
|
||||
let repo_for_resolve = Arc::clone(&repo);
|
||||
let outcome = resolve_pending_download_urls(
|
||||
|
||||
Reference in New Issue
Block a user