瀏覽代碼

Add some logic so force downloading will "restart" the downloader.

tags/0.1.0
Bauke 10 月之前
父節點
當前提交
da09b82b72
簽署人: Bauke <me@bauke.xyz> GPG Key ID: C1C0F29952BCF558
共有 1 個文件被更改,包括 21 次插入5 次删除
  1. +21
    -5
      source/downloader/mod.rs

+ 21
- 5
source/downloader/mod.rs 查看文件

@@ -108,18 +108,34 @@ pub fn download_and_save_feeds(
}

if let Some(receiver) = receiver {
match receiver.try_recv() {
let instruction = match receiver.try_recv() {
Ok(value) => {
println!(
"[DL] Received instruction {:?} while downloading, ignoring it.",
value,
);
println!("[DL] Received instruction {:?} while downloading.", value,);
Some(value)
}
Err(err) => {
if err != mpsc::TryRecvError::Empty {
println!("[DL] Error attempting to receive from channel: {}", err);
break;
}
None
}
};

if let Some(instruction) = instruction {
// If we receive the force download all instruction and we're not already force downloading
// run this same function with force download all enabled.
if instruction == DownloaderInstruction::ForceDownloadAll
&& !force_download
{
println!(
"[DL] Restarting the downloader with force download enabled."
);
download_and_save_feeds(&conn, true, false, Some(&receiver)).unwrap();
break;
} else {
// Otherwise just print that we're ignoring the instruction.
println!("[DL] Ignoring the {:?} instruction.", instruction);
}
}
}


Loading…
取消
儲存