aboutsummaryrefslogtreecommitdiffstats
path: root/sys/nixpkgs/pkgs/yt
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-01-21 14:33:38 +0100
committerSoispha <soispha@vhack.eu>2024-01-21 14:33:38 +0100
commit1ccb1246641265f384e51f7a72f0589a1dd28fad (patch)
treee064b818b9a3e1173cf24a4f7dba05da4530cdea /sys/nixpkgs/pkgs/yt
parentfeat(sys/nixpkgs/yt): Add support for the 'url' command (diff)
downloadnixos-config-1ccb1246641265f384e51f7a72f0589a1dd28fad.zip
fix(sys/nixpkgs/yt): Ensure that the downloader downloads everything
Diffstat (limited to '')
-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),
}
}