Skip to content

Commit cd1f81d

Browse files
committed
Add processing configuration for file destination path
1 parent 8036592 commit cd1f81d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ description = "Bmpcc transcoded videos"
1616
[immich]
1717
server_url = "https://immich.your.domain"
1818

19+
[processing]
20+
destination_path = "/mnt/nand/scratch/shoebox/"
1921

2022
#[[paths]]
2123
#root_path = "/mnt/immich/app/upload/library/Jacob/"

src/filesystem/fs_prepare.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ use log::{info, warn};
44
use std::fs;
55
use std::path::Path;
66

7-
pub fn copy_files_to_destination(file_paths: &Vec<String>, destination_root: String) -> Result<()> {
7+
pub fn copy_files_to_destination(
8+
file_paths: &Vec<String>,
9+
destination_root: &String,
10+
) -> Result<()> {
811
let now: DateTime<Local> = Local::now();
912
let dir_name = now.format("%Y-%m-%d_%H-%M-%S").to_string(); // Format the date and time
10-
let destination_path = Path::new(&destination_root).join(&dir_name); // Create unique directory
13+
let destination_path = Path::new(destination_root).join(&dir_name); // Create unique directory
1114

1215
// Create the destination directory
1316
fs::create_dir_all(&destination_path)?;

src/pages/search.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::components::shadcn_card::{
55
};
66
use crate::lib_models::{MediaWeb, VideoMetadata};
77
use crate::pages::review::FallbackView;
8+
use crate::settings::settings;
89
use leptos::attr::{controls, selected};
910
use leptos::either::Either;
1011
use leptos::html::{video, Video};
@@ -142,14 +143,14 @@ pub async fn process_selected_media(ids: Vec<i32>) -> Result<(), ServerFnError>
142143
// Perform server-side actions with the selected IDs
143144
use crate::database::pg_calls::get_file_paths_by_ids;
144145
use crate::filesystem::fs_prepare::copy_files_to_destination;
146+
let settings = settings();
147+
let destination_path = &settings.processing.destination_path;
145148
log!("Server received IDs: {:?}", ids);
146149
//get filepaths
147150
let file_paths = get_file_paths_by_ids(ids);
148151
//copy files
149152
if let Ok(file_paths) = file_paths {
150-
let prepare_files =
151-
//TODO: Add config for destination
152-
copy_files_to_destination(&file_paths, "/mnt/nand/scratch/shoebox".to_string());
153+
let prepare_files = copy_files_to_destination(&file_paths, destination_path);
153154
if let Ok(prepare_files) = prepare_files {
154155
log!("Files prepared");
155156
Ok(())

src/settings.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ pub struct Settings {
1111
pub paths: Vec<PathConfig>,
1212
pub immich: ImmichConfig,
1313
pub immich_album: ImmichAlbumConfig,
14+
pub processing: ProcessingConfig,
15+
}
16+
17+
#[derive(Debug, Deserialize)]
18+
pub struct ProcessingConfig {
19+
pub destination_path: String,
1420
}
1521

1622
#[derive(Debug, Deserialize)]

0 commit comments

Comments
 (0)