diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-03 19:14:26 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-03 19:14:26 +0200 |
commit | c71a10717392cc321b97e3f2173645e78c263488 (patch) | |
tree | d55187e9417bc186735c3615f5e3d0f07dfb6ffb | |
parent | df768b33d0098a479b21abe30853537b4be3a813 (diff) | |
download | jellything-c71a10717392cc321b97e3f2173645e78c263488.tar jellything-c71a10717392cc321b97e3f2173645e78c263488.tar.bz2 jellything-c71a10717392cc321b97e3f2173645e78c263488.tar.zst |
symlink sources
-rw-r--r-- | server/src/import.rs | 6 | ||||
-rw-r--r-- | tools/src/bin/import.rs | 26 |
2 files changed, 25 insertions, 7 deletions
diff --git a/server/src/import.rs b/server/src/import.rs index 4750196..6ea8268 100644 --- a/server/src/import.rs +++ b/server/src/import.rs @@ -9,7 +9,7 @@ use async_recursion::async_recursion; use base64::Engine; use jellyclient::Session; use jellycommon::{AssetLocation, MediaSource, Node, NodePrivate, RemoteImportOptions}; -use log::{error, info}; +use log::{debug, error, info}; use std::{ ffi::OsStr, fs::File, os::unix::prelude::OsStrExt, path::PathBuf, str::FromStr, sync::LazyLock, }; @@ -105,7 +105,7 @@ pub async fn import_path( .await .context("federated import")?; } else { - info!("adding {identifier}"); + debug!("adding {identifier}"); data.public.parent = parent; db.node.insert(&identifier, &data)?; } @@ -163,7 +163,7 @@ async fn import_remote( node.public.parent = parent; node.public.federated = Some(opts.host.clone()); - info!("adding {identifier}"); + debug!("adding {identifier}"); db.node.insert(identifier, &node)?; Ok(()) diff --git a/tools/src/bin/import.rs b/tools/src/bin/import.rs index a27b247..471a669 100644 --- a/tools/src/bin/import.rs +++ b/tools/src/bin/import.rs @@ -10,7 +10,12 @@ use jellymatroska::read::EbmlReader; use jellyremuxer::import::import_read; use jellytools::tmdb::{tmdb_details, tmdb_image, tmdb_search}; use log::info; -use std::{fs::File, io::stdin, path::PathBuf, process::exit}; +use std::{ + fs::{remove_file, File}, + io::stdin, + path::PathBuf, + process::exit, +}; #[derive(Parser)] struct Args { @@ -27,6 +32,10 @@ enum Action { title: Option<String>, #[arg(short = 'T', long)] tmdb: Option<String>, + #[arg(long)] + copy: bool, + #[arg(long)] + r#move: bool, #[arg(short, long)] input: Option<PathBuf>, #[arg(short, long)] @@ -64,6 +73,8 @@ fn main() -> anyhow::Result<()> { tmdb: id, input, series, + copy, + r#move, } => { assert!(series || input.is_some(), "series or input required"); let kind = if series { "tv" } else { "movie" }; @@ -133,9 +144,16 @@ fn main() -> anyhow::Result<()> { if let Some(input) = input { let source_path = path.join(format!("source.mkv")); - // std::fs::rename(&input, &source_path)?; - // std::os::unix::fs::symlink(&input, &source_path)?; - std::fs::copy(&input, &source_path)?; + if r#move { + std::fs::rename(&input, &source_path)?; + } else if copy { + std::fs::copy(&input, &source_path)?; + } else { + if source_path.is_symlink() { + remove_file(&source_path)?; + } + std::os::unix::fs::symlink(&input, &source_path)?; + } let input = File::open(&source_path).unwrap(); let mut input = EbmlReader::new(input); let (tracks, local_tracks, seek_index, duration) = |