Fix a broken test on Windows

This commit is contained in:
Igor Katson 2024-08-23 19:37:31 +01:00
parent 9e7b656f0b
commit 0c06601b34
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
3 changed files with 22 additions and 16 deletions

View file

@ -208,19 +208,19 @@ fn merge_two_optional_streams<T>(
) -> Option<BoxStream<'static, T>> {
match (s1, s2) {
(Some(s1), None) => {
debug!("merge_two_optional_streams: using first");
trace!("merge_two_optional_streams: using first");
Some(Box::pin(s1))
}
(None, Some(s2)) => {
debug!("merge_two_optional_streams: using second");
trace!("merge_two_optional_streams: using second");
Some(Box::pin(s2))
}
(Some(s1), Some(s2)) => {
debug!("merge_two_optional_streams: using both");
trace!("merge_two_optional_streams: using both");
Some(Box::pin(merge_streams(s1, s2)))
}
(None, None) => {
debug!("merge_two_optional_streams: using none");
trace!("merge_two_optional_streams: using none");
None
}
}
@ -909,7 +909,7 @@ impl Session {
rx,
seen,
} => {
debug!(?info, "received result from DHT");
trace!(?info, "received result from DHT");
let trackers = magnet.trackers.into_iter().unique().collect_vec();
InternalAddResult {
info_hash,
@ -924,7 +924,7 @@ impl Session {
initial_peers: {
let seen = seen.into_iter().collect_vec();
for peer in &seen {
debug!(?peer, "seen")
trace!(?peer, "seen")
}
seen
},
@ -1045,7 +1045,7 @@ impl Session {
info_bytes,
} = add_res;
debug!("Torrent info: {:#?}", &info);
trace!("Torrent info: {:#?}", &info);
let only_files = compute_only_files(
&info,

View file

@ -7,7 +7,7 @@ use anyhow::Context;
use librqbit_core::lengths::Lengths;
use size_format::SizeFormatterBinary as SF;
use tracing::{debug, info, warn};
use tracing::{info, trace, warn};
use crate::{
api::TorrentIdOrHash,
@ -159,7 +159,7 @@ impl TorrentStateInitializing {
fi.relative_filename, fi.len, err
);
} else {
debug!(
trace!(
"Set length for file {:?} to {} in {:?}",
fi.relative_filename,
SF::new(fi.len),

View file

@ -62,15 +62,21 @@ impl TorrentFileTreeNode {
match self.real_torrent_file_id {
Some(fid) => {
let filename = &torrent.shared().file_infos[fid].relative_filename;
let last_url_bit = filename.to_str().unwrap_or(&self.title);
return ItemOrContainer::Item(Item {
// Torrent path joined with "/"
let last_url_bit = torrent
.shared()
.info
.iter_filenames_and_lengths()
.ok()
.and_then(|mut it| it.nth(fid))
.and_then(|(fi, _)| fi.to_vec().ok())
.map(|components| components.join("/"))
.unwrap_or_else(|| self.title.clone());
ItemOrContainer::Item(Item {
id: encoded_id,
parent_id: encoded_parent_id,
title: self.title.clone(),
mime_type: mime_guess::from_path(
&torrent.shared().file_infos[fid].relative_filename,
)
.first(),
mime_type: mime_guess::from_path(filename).first(),
url: format!(
"http://{}:{}/torrents/{}/stream/{}/{}",
adapter.hostname,
@ -79,7 +85,7 @@ impl TorrentFileTreeNode {
fid,
last_url_bit
),
});
})
}
None => ItemOrContainer::Container(Container {
id: encoded_id,