Skip to content

Commit

Permalink
fixed filtering for root-based files for flat repositories. also move…
Browse files Browse the repository at this point in the history
…d around the display implementation to simplify some things
  • Loading branch information
cyr committed Jan 20, 2025
1 parent 36c72e2 commit 59d6cb7
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 31 deletions.
29 changes: 28 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::cmp::Ordering;
use std::{cmp::Ordering, fmt::Display};
use compact_str::{format_compact, CompactString, ToCompactString};
use tokio::io::{BufReader, AsyncBufReadExt};

Expand Down Expand Up @@ -240,4 +240,31 @@ impl MirrorOpts {
format_compact!("dists/{}", self.suite)
}
}
}

impl Display for MirrorOpts {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.packages && self.source {
f.write_str("deb+deb-src")?
} else if self.packages {
f.write_str("deb")?
} else if self.source {
f.write_str("deb-src")?
}

if self.flat() {
f.write_fmt(format_args!(
" {} (flat)",
self.url
))
} else {
f.write_fmt(format_args!(
" {} {}[{}] {}",
self.url,
self.suite,
self.arch.join(", "),
self.components.join(" ")
))
}
}
}
6 changes: 6 additions & 0 deletions src/metadata/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,12 @@ impl Iterator for ReleaseFileIterator<'_> {
let component = component.to_str()
.expect("path should be utf8");

if parts.peek().is_none() {
if self.file_prefix_filter.iter().any(|v| component.starts_with(v.as_str())) {
return Some((path.into(), file_entry))
}
}

if !self.opts.components.iter().any(|v| v.as_str() == component) {
continue
}
Expand Down
16 changes: 1 addition & 15 deletions src/mirror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,7 @@ impl MirrorState {

impl Display for MirrorState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.opts.packages && self.opts.source {
f.write_str("deb+deb-src")?
} else if self.opts.packages {
f.write_str("deb")?
} else if self.opts.source {
f.write_str("deb-src")?
}

f.write_fmt(format_args!(
" {} {}[{}] {}",
self.opts.url,
self.opts.suite,
self.opts.arch.join(", "),
self.opts.components.join(" ")
))
self.opts.fmt(f)
}
}

Expand Down
16 changes: 1 addition & 15 deletions src/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,7 @@ pub struct VerifyState {

impl Display for VerifyState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if self.opts.packages && self.opts.source {
f.write_str("deb+deb-src")?
} else if self.opts.packages {
f.write_str("deb")?
} else if self.opts.source {
f.write_str("deb-src")?
}

f.write_fmt(format_args!(
" {} {}[{}] {}",
self.opts.url,
self.opts.suite,
self.opts.arch.join(", "),
self.opts.components.join(" ")
))
self.opts.fmt(f)
}
}
#[derive(Default)]
Expand Down

0 comments on commit 59d6cb7

Please sign in to comment.