Browse Source

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

tags/0.1.0
Bauke 5 months ago
parent
commit
da09b82b72
Signed by: Bauke <me@bauke.xyz> GPG Key ID: C1C0F29952BCF558
1 changed files with 21 additions and 5 deletions
  1. +21
    -5
      source/downloader/mod.rs

+ 21
- 5
source/downloader/mod.rs View File

@@ -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…
Cancel
Save