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