feat(lib): carry audio attributes in browse and folder listings
A browse listed each file as a name and a size, so a searcher who saw a bitrate in a search reply lost it the moment they opened the sharer's files. Listings (codes 5 and 37) now carry each file's attributes the way Nicotine+ sends them, as a SharedFileEntry with name, size and attributes in place of the (name, size) pair; the CLI's browse record gains bitrate and duration, and the daemon protocol moves to version 2 for the new listing shape.
This commit is contained in:
@@ -123,13 +123,13 @@ pub fn build_browse_tree(directories: &[SharedDirectory]) -> BuiltTree {
|
||||
|
||||
// File paths come from the original name so downloads match exactly.
|
||||
let dir_path = dir.name.trim_end_matches('\\');
|
||||
for (basename, size) in &dir.files {
|
||||
for file in &dir.files {
|
||||
let file_path = if dir_path.is_empty() {
|
||||
basename.clone()
|
||||
file.name.clone()
|
||||
} else {
|
||||
format!("{dir_path}\\{basename}")
|
||||
format!("{dir_path}\\{}", file.name)
|
||||
};
|
||||
node.files.push((basename.clone(), *size, file_path));
|
||||
node.files.push((file.name.clone(), file.size, file_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,14 @@ mod tests {
|
||||
fn dir(name: &str, files: &[(&str, u64)]) -> SharedDirectory {
|
||||
SharedDirectory {
|
||||
name: name.to_string(),
|
||||
files: files.iter().map(|(n, s)| ((*n).to_string(), *s)).collect(),
|
||||
files: files
|
||||
.iter()
|
||||
.map(|(n, s)| soulseek_rs::SharedFileEntry {
|
||||
name: (*n).to_string(),
|
||||
size: *s,
|
||||
attributes: Vec::new(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user