Implement the video adapter to retrieve the root folder content.
This commit is contained in:
@@ -6,6 +6,7 @@ use uuid::Uuid;
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct VideoAdapter {
|
||||
|
||||
}
|
||||
@@ -50,20 +51,16 @@ impl VideoAdapter {
|
||||
Ok(items)
|
||||
}
|
||||
|
||||
pub fn get_all_library_items_from_db(&self) -> Result<Vec<LibraryRawItem>, VideoError> {
|
||||
fn get_all_library_items_from_db(&self) -> Result<Vec<LibraryRawItem>, VideoError> {
|
||||
Ok(vec!())
|
||||
}
|
||||
|
||||
fn merge_item_lists(file_system_items: Vec<LibraryRawItem>, db_items: Vec<LibraryRawItem>) -> Vec<LibraryRawItem> {
|
||||
let mut all_items: Vec<LibraryRawItem> = Vec::new();
|
||||
let file_system_items_which_are_not_in_database: Vec<LibraryRawItem> = file_system_items.into_iter()
|
||||
.filter(|file_system_item| !Self::does_item_belong_to_db_items(&db_items, &file_system_item))
|
||||
.collect();
|
||||
|
||||
db_items.iter().for_each(|item| all_items.push(*item));
|
||||
|
||||
file_system_items.iter()
|
||||
.filter(|file_system_item| Self::does_item_belong_to_db_items(&db_items, file_system_item))
|
||||
.for_each(|file_system_item| all_items.push(*file_system_item));
|
||||
|
||||
all_items
|
||||
db_items.into_iter().chain(file_system_items_which_are_not_in_database).collect()
|
||||
}
|
||||
|
||||
fn does_item_belong_to_db_items(database_items: &Vec<LibraryRawItem>, file_system_item: &LibraryRawItem) -> bool {
|
||||
@@ -90,11 +87,15 @@ impl VideoPort for VideoAdapter {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn save(&self, library_item: LibraryItem) -> Result<(), VideoError> {
|
||||
fn save(&self, library_item: &LibraryItem) -> Result<(), VideoError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn save_all(&self, library_items: &Vec<LibraryItem>) -> Result<(), VideoError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn clone_box(&self) -> Box<dyn VideoPort> {
|
||||
todo!()
|
||||
Box::new(self.clone())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user