Implement the service to list items in the root folder.
This commit is contained in:
@@ -5,7 +5,7 @@ use std::io::{BufRead, BufReader};
|
||||
use std::path::Path;
|
||||
use std::io::Read;
|
||||
use lumiere_domain::video::error::VideoError;
|
||||
use lumiere_domain::video::model::library_item::LibraryItem;
|
||||
use lumiere_domain::video::model::library_item::{LibraryItem, ReadLibraryItem};
|
||||
use lumiere_domain::video::port::VideoPort;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -19,15 +19,12 @@ impl VideoService {
|
||||
}
|
||||
|
||||
pub fn list_root_folder(self) -> Result<Vec<LibraryItem>, VideoError> {
|
||||
let library_items = self.video_port.list_root_folder()?;
|
||||
|
||||
let items_without_id = library_items.iter().filter(|item| item.id == None);
|
||||
// generate a new Uuid for each item without id
|
||||
// assign this new Uuid to the item
|
||||
// save the item by using the method video_port.save
|
||||
// replace the items_without_id by modified items_without_id
|
||||
|
||||
Ok(vec!())
|
||||
let read_items_with_possibly_no_id = self.video_port.list_root_folder()?;
|
||||
let items_with_id = read_items_with_possibly_no_id.iter()
|
||||
.map(ReadLibraryItem::map_to_library_item)
|
||||
.collect();
|
||||
self.video_port.save_all(items_with_id);
|
||||
Ok(items_with_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user