Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TODO.MD
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ fix color buttons on windows


number of parallel downloads: I update it to 10, goes back to 3
cookie_db_path on windows
23 changes: 23 additions & 0 deletions src-tauri/src/commands/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ pub async fn refresh_download_settings(manager: State<'_, DownloadManager>) -> R
.map_err(|e| e.to_string())
}

#[tauri::command]
pub async fn reconcile_downloads(manager: State<'_, DownloadManager>) -> Result<(), String> {
manager
.send(DownloadCommand::ReconcileState)
.await
.map_err(|e| e.to_string())
}

#[tauri::command]
pub async fn refresh_downloads_snapshot(
manager: State<'_, DownloadManager>,
) -> Result<Vec<crate::database::UiBacklogRow>, String> {
let (reply_tx, reply_rx) = tokio::sync::oneshot::channel();
manager
.send(DownloadCommand::RefreshSnapshot { reply: reply_tx })
.await
.map_err(|e| e.to_string())?;
reply_rx
.await
.map_err(|e| format!("snapshot channel closed: {e}"))?
}

fn sanitize_url(raw: &str) -> String {
raw.trim()
.replace("#__audio_only__", "")
Expand Down Expand Up @@ -134,6 +156,7 @@ fn ensure_row_for_url(url: &str, force_audio: Option<bool>) -> Result<(i64, bool
status: DownloadStatus::Queued,
path: "unknown_path".into(),
image_set_id: None,
last_error: None,
date_added: Utc::now(),
date_downloaded: None,
};
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/src/commands/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ pub async fn read_csv_from_path(app: tauri::AppHandle, path: String) -> Result<S

match super::import::import_csv_text(csv_text.clone()).await {
Ok(n) => {
println!("[BACKEND] [files] imported {n} rows (drag-drop) from {}", path);
println!(
"[BACKEND] [files] imported {n} rows (drag-drop) from {}",
path
);
let _ = app.emit("import_completed", n);
}
Err(e) => {
Expand Down
11 changes: 9 additions & 2 deletions src-tauri/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
/// Returns the number of successfully imported rows.

#[tauri::command]
pub async fn import_csv_to_db(csv_text: Option<String>, csvText: Option<String>) -> Result<u64, String> {
pub async fn import_csv_to_db(
csv_text: Option<String>,
csvText: Option<String>,
) -> Result<u64, String> {
// Accept both snake_case and camelCase keys from JS.
let csv_text = csv_text
.or(csvText)
Expand Down Expand Up @@ -104,7 +107,10 @@ pub async fn import_csv_text(csv_text: String) -> Result<u64, String> {

let platform_token = format!("{:?}", platform).to_lowercase();
let origin_token = format!("{:?}", origin).to_lowercase();
if db.link_exists_in_collection(&link, &platform_token, &handle, &origin_token).unwrap_or(false) {
if db
.link_exists_in_collection(&link, &platform_token, &handle, &origin_token)
.unwrap_or(false)
{
continue;
}

Expand All @@ -120,6 +126,7 @@ pub async fn import_csv_text(csv_text: String) -> Result<u64, String> {
status: crate::database::DownloadStatus::Backlog,
path: String::new(),
image_set_id: None,
last_error: None,
date_added: chrono::Utc::now(),
date_downloaded: None,
};
Expand Down
6 changes: 5 additions & 1 deletion src-tauri/src/commands/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,9 @@ pub async fn check_sidecar_tools(app: tauri::AppHandle) -> Result<SidecarCheck,
let gal_ok = on_path(&["gallery-dl", "gallery_dl"]);
let ffmpeg_ok = on_path(&["ffmpeg"]);

Ok(SidecarCheck {yt_dlp: yt_ok, gallery_dl: gal_ok, ffmpeg: ffmpeg_ok})
Ok(SidecarCheck {
yt_dlp: yt_ok,
gallery_dl: gal_ok,
ffmpeg: ffmpeg_ok,
})
}
Loading
Loading