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

View file

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

View file

@ -62,15 +62,21 @@ impl TorrentFileTreeNode {
match self.real_torrent_file_id { match self.real_torrent_file_id {
Some(fid) => { Some(fid) => {
let filename = &torrent.shared().file_infos[fid].relative_filename; let filename = &torrent.shared().file_infos[fid].relative_filename;
let last_url_bit = filename.to_str().unwrap_or(&self.title); // Torrent path joined with "/"
return ItemOrContainer::Item(Item { 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, id: encoded_id,
parent_id: encoded_parent_id, parent_id: encoded_parent_id,
title: self.title.clone(), title: self.title.clone(),
mime_type: mime_guess::from_path( mime_type: mime_guess::from_path(filename).first(),
&torrent.shared().file_infos[fid].relative_filename,
)
.first(),
url: format!( url: format!(
"http://{}:{}/torrents/{}/stream/{}/{}", "http://{}:{}/torrents/{}/stream/{}/{}",
adapter.hostname, adapter.hostname,
@ -79,7 +85,7 @@ impl TorrentFileTreeNode {
fid, fid,
last_url_bit last_url_bit
), ),
}); })
} }
None => ItemOrContainer::Container(Container { None => ItemOrContainer::Container(Container {
id: encoded_id, id: encoded_id,