aboutsummaryrefslogtreecommitdiffstats
path: root/sys/nixpkgs/pkgs/yt/src/downloader.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sys/nixpkgs/pkgs/yt/src/downloader.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/nixpkgs/pkgs/yt/src/downloader.rs b/sys/nixpkgs/pkgs/yt/src/downloader.rs
index 34627f70..b30c49a2 100644
--- a/sys/nixpkgs/pkgs/yt/src/downloader.rs
+++ b/sys/nixpkgs/pkgs/yt/src/downloader.rs
@@ -21,6 +21,17 @@ pub struct Downloadable {
pub id: Option<u32>,
}
+impl std::fmt::Display for Downloadable {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
+ write!(
+ f,
+ "{}|{}",
+ self.url.as_str().replace('|', ";"),
+ self.id.unwrap_or(0),
+ )
+ }
+}
+
pub struct Downloader {
sent: usize,
download_thread: JoinHandle<Result<()>>,
@@ -34,8 +45,8 @@ impl Downloader {
let (itx, irx): (Sender<Downloadable>, Receiver<Downloadable>) = mpsc::channel();
let (otx, orx) = mpsc::channel();
let jh = thread::spawn(move || -> Result<()> {
- while let Some(pt) = irx.recv().ok() {
- debug!("Got '{}|{}' to be downloaded", pt.url, pt.id.unwrap_or(0));
+ while let Ok(pt) = irx.recv() {
+ debug!("Got '{}' to be downloaded", pt);
let path = download_url(&pt.url)
.with_context(|| format!("Failed to download url: '{}'", &pt.url))?;
otx.send((path, pt.id)).expect("Should not be dropped");