about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/yt
diff options
context:
space:
mode:
Diffstat (limited to 'sys/nixpkgs/pkgs/yt')
-rw-r--r--sys/nixpkgs/pkgs/yt/src/bin/yt/main.rs2
-rw-r--r--sys/nixpkgs/pkgs/yt/src/downloader.rs12
2 files changed, 8 insertions, 6 deletions
diff --git a/sys/nixpkgs/pkgs/yt/src/bin/yt/main.rs b/sys/nixpkgs/pkgs/yt/src/bin/yt/main.rs
index f3c16613..37348834 100644
--- a/sys/nixpkgs/pkgs/yt/src/bin/yt/main.rs
+++ b/sys/nixpkgs/pkgs/yt/src/bin/yt/main.rs
@@ -32,7 +32,7 @@ fn main() -> Result<()> {
     };
 
     let temp_file = Builder::new()
-        .prefix("yt_video_select")
+        .prefix("yt_video_select-")
         .suffix(".yts")
         .rand_bytes(6)
         .tempfile()
diff --git a/sys/nixpkgs/pkgs/yt/src/downloader.rs b/sys/nixpkgs/pkgs/yt/src/downloader.rs
index b30c49a2..f29f4a3b 100644
--- a/sys/nixpkgs/pkgs/yt/src/downloader.rs
+++ b/sys/nixpkgs/pkgs/yt/src/downloader.rs
@@ -74,8 +74,9 @@ impl Downloader {
     pub fn add(&mut self, number_to_add: u32) -> Result<()> {
         debug!("Adding {} to be downloaded concurrently", number_to_add);
         for _ in 0..number_to_add {
-            let pt = self.playspec.pop().context("No more playthings to pop")?;
+            let pt = self.playspec.pop().expect("This call should be guarded");
             self.itx.as_ref().expect("Should still be valid").send(pt)?;
+            self.sent += 1;
         }
         Ok(())
     }
@@ -86,9 +87,7 @@ impl Downloader {
         match self.orx.recv() {
             Ok(ok) => {
                 debug!("Output downloaded to: {}", ok.0.display());
-                self.sent += 1;
-                if self.sent < self.playspec.len() {
-                    debug!("Will add 1");
+                if !self.playspec.is_empty() {
                     self.add(1).ok()?;
                 } else {
                     debug!(
@@ -107,10 +106,13 @@ impl Downloader {
             }
         }
     }
+
     pub fn drop(self) -> anyhow::Result<()> {
+        // Check that we really downloaded everything
+        assert_eq!(self.playspec.len(), 0);
         match self.download_thread.join() {
             Ok(ok) => ok,
-            Err(err) => panic!("Can't join thread: '{:#?}'", err),
+            Err(err) => panic!("Failed to join downloader thread: '{:#?}'", err),
         }
     }