Implement parent_id=-1
This commit is contained in:
parent
8ab3d4d428
commit
79a8451519
3 changed files with 10 additions and 10 deletions
|
|
@ -74,7 +74,7 @@ impl TorrentFileTreeNode {
|
|||
.unwrap_or_else(|| self.title.clone());
|
||||
ItemOrContainer::Item(Item {
|
||||
id: encoded_id,
|
||||
parent_id: encoded_parent_id.map(|id| id as isize),
|
||||
parent_id: encoded_parent_id.unwrap_or_default(),
|
||||
title: self.title.clone(),
|
||||
mime_type: mime_guess::from_path(filename).first(),
|
||||
url: format!(
|
||||
|
|
@ -124,7 +124,7 @@ impl TorrentFileTree {
|
|||
.context("bug")??;
|
||||
let root_node = TorrentFileTreeNode {
|
||||
title: filename.to_owned(),
|
||||
parent_id: None,
|
||||
parent_id: Some(0),
|
||||
children: vec![],
|
||||
real_torrent_file_id: Some(0),
|
||||
};
|
||||
|
|
@ -220,7 +220,7 @@ impl UpnpServerSessionAdapter {
|
|||
);
|
||||
Some(ItemOrContainer::Item(Item {
|
||||
id: upnp_id,
|
||||
parent_id: None,
|
||||
parent_id: 0,
|
||||
title,
|
||||
mime_type,
|
||||
url,
|
||||
|
|
@ -238,7 +238,7 @@ impl UpnpServerSessionAdapter {
|
|||
// Create a folder
|
||||
Some(ItemOrContainer::Container(Container {
|
||||
id: upnp_id,
|
||||
parent_id: None,
|
||||
parent_id: Some(0),
|
||||
title,
|
||||
children_count: None,
|
||||
}))
|
||||
|
|
@ -572,14 +572,14 @@ mod tests {
|
|||
vec![
|
||||
ItemOrContainer::Item(Item {
|
||||
id: encode_id(0, 0),
|
||||
parent_id: None,
|
||||
parent_id: Some(0),
|
||||
title: "f1".into(),
|
||||
mime_type: None,
|
||||
url: "http://127.0.0.1:9005/torrents/0/stream/0/f1".into()
|
||||
}),
|
||||
ItemOrContainer::Container(Container {
|
||||
id: encode_id(0, 1),
|
||||
parent_id: None,
|
||||
parent_id: Some(0),
|
||||
children_count: None,
|
||||
title: "t2".into()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
mime_type: Some(Mime::from_str("video/x-matroska")?),
|
||||
url: "http://192.168.0.165:3030/torrents/4/stream/0/file.mkv".to_owned(),
|
||||
id: 1,
|
||||
parent_id: Some(0),
|
||||
parent_id: 0,
|
||||
})];
|
||||
|
||||
const HTTP_PORT: u16 = 9005;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ pub mod browse {
|
|||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Item {
|
||||
pub id: usize,
|
||||
pub parent_id: Option<isize>,
|
||||
pub parent_id: usize,
|
||||
pub title: String,
|
||||
pub mime_type: Option<mime_guess::Mime>,
|
||||
pub url: String,
|
||||
|
|
@ -97,7 +97,7 @@ pub mod browse {
|
|||
"../resources/templates/content_directory/control/browse/item.tmpl.xml"
|
||||
),
|
||||
id = item.id,
|
||||
parent_id = item.parent_id.unwrap_or(-1),
|
||||
parent_id = item.parent_id,
|
||||
mime_type = mime,
|
||||
url = item.url,
|
||||
upnp_class = upnp_class,
|
||||
|
|
@ -115,7 +115,7 @@ pub mod browse {
|
|||
"../resources/templates/content_directory/control/browse/container.tmpl.xml"
|
||||
),
|
||||
id = item.id,
|
||||
parent_id = item.parent_id.unwrap_or(0),
|
||||
parent_id = item.parent_id.map(|p| p as isize).unwrap_or(-1),
|
||||
title = item.title,
|
||||
childCountTag = child_count_tag
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue