Feedback-Runde: lokale Titel sofort beim Start (ffprobe-Scan vor Online-Laden), Löschen-Bug (Vorexist-Check), Nur-Streaming-Merkliste mit ▶-Button statt Download

This commit is contained in:
2026-11-06 20:15:48 +01:00
parent 5b1749ec78
commit e7f7f26ded
4 changed files with 97 additions and 11 deletions

View File

@ -68,6 +68,30 @@ fn manifest_path() -> PathBuf {
download_root().join("queue.json")
}
fn stream_only_path() -> PathBuf {
download_root().join("nicht-ladbar.json")
}
/// Liste der Titel, die Audible bewusst nicht als Datei liefert.
pub fn stream_only_load() -> Vec<String> {
fs::read_to_string(stream_only_path())
.ok()
.and_then(|txt| serde_json::from_str(&txt).ok())
.unwrap_or_default()
}
fn stream_only_add(asin: &str) {
let mut set: Vec<String> = stream_only_load();
if !set.iter().any(|a| a == asin) {
set.push(asin.to_string());
let _ = fs::create_dir_all(download_root());
let _ = fs::write(
stream_only_path(),
serde_json::to_vec(&set).unwrap_or_default(),
);
}
}
impl DownloadMgr {
/// Erstellt den Manager; laufende/offene Einträge aus dem Manifest
/// werden nach Neustart erneut eingereiht.
@ -196,15 +220,17 @@ impl DownloadMgr {
self.persist_locked(&g);
drop(g);
let dir = download_root().join(&asin);
if dir.exists() {
let cache_existed = dir.exists();
if cache_existed {
fs::remove_dir_all(&dir).map_err(|e| format!("Verzeichnis löschen: {e}"))?;
}
// lokales Buch entfernen (bestehend seit T-014)
let book_dir = crate::audible::books_dir().join(&asin);
if book_dir.exists() {
let book_existed = book_dir.exists();
if book_existed {
fs::remove_dir_all(&book_dir).map_err(|e| format!("Buch löschen: {e}"))?;
}
if !removed && !book_dir.exists() {
if !removed && !cache_existed && !book_existed {
return Err(format!("{} hat nichts zu löschen", asin));
}
Ok(())
@ -258,6 +284,10 @@ impl DownloadMgr {
it.status = status;
it.bytes = bytes;
it.msg = msg;
// Nicht Ladenbares einmal merken — für „Nur Streaming“-Chips
if it.status == DlStatus::Failed && it.msg.contains("nicht als Datei") {
stream_only_add(asin);
}
let snapshot = it.clone();
self.persist_locked(&g);
drop(g);
@ -686,6 +716,20 @@ mod tests {
let _ = fs::remove_dir_all(&tmp);
}
#[test]
fn stream_only_merkliste_roundtrip() {
let root = download_root().join("streamtest");
let _ = fs::remove_dir_all(&root);
let pfad = root.join("nicht-ladbar.json");
fs::create_dir_all(&root).unwrap();
let set = vec!["B015HG6T6A".to_string()];
fs::write(&pfad, serde_json::to_vec(&set).unwrap()).unwrap();
let gelesen: Vec<String> =
serde_json::from_str(&fs::read_to_string(&pfad).unwrap()).unwrap();
assert_eq!(gelesen, vec!["B015HG6T6A"]);
let _ = fs::remove_dir_all(&root);
}
#[test]
fn dl_item_serde_status() {
let it = DlItem {

View File

@ -60,6 +60,14 @@ async fn get_local_books() -> Result<Vec<Book>, String> {
.await
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))
}
/// Titel, die Audible bewusst nicht als Datei liefert (Nur-Streaming).
#[tauri::command]
async fn stream_only() -> Result<Vec<String>, String> {
tauri::async_runtime::spawn_blocking(download::stream_only_load)
.await
.map_err(|e| format!("Hintergrundthread fehlgeschlagen: {e}"))
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
@ -77,6 +85,7 @@ pub fn run() {
start_decrypt,
get_library,
get_local_books,
stream_only,
download_list,
download_enqueue,
download_cancel,