feat: use local copy when NAS_HOST is localhost
Co-authored-by: aider (gemini/gemini-2.5-pro-preview-05-06) <aider@aider.chat>
This commit is contained in:
parent
26824c458d
commit
8d58e50847
2 changed files with 20 additions and 11 deletions
|
|
@ -8,4 +8,5 @@ edition = "2021"
|
|||
[dependencies]
|
||||
anyhow = "1.0.82"
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
fs_extra = "1.3.0"
|
||||
tempfile = "3.10.1"
|
||||
|
|
|
|||
10
src/main.rs
10
src/main.rs
|
|
@ -79,7 +79,14 @@ fn transfer_files(source_path: &Path) -> Result<()> {
|
|||
let is_empty = fs::read_dir(source_path)?.next().is_none();
|
||||
|
||||
if !is_empty {
|
||||
println!("[INFO] Transferring files to NAS...");
|
||||
if NAS_HOST == "localhost" {
|
||||
println!("[INFO] NAS_HOST is localhost, copying files locally...");
|
||||
let mut options = fs_extra::dir::CopyOptions::new();
|
||||
options.content_only = true;
|
||||
fs_extra::dir::copy(source_path, NAS_PATH, &options)
|
||||
.context("Failed to copy files locally")?;
|
||||
} else {
|
||||
println!("[INFO] Transferring files to NAS via scp...");
|
||||
let mut scp_cmd = Command::new("scp");
|
||||
let source = format!(
|
||||
"{}/.",
|
||||
|
|
@ -92,6 +99,7 @@ fn transfer_files(source_path: &Path) -> Result<()> {
|
|||
if !status.success() {
|
||||
anyhow::bail!("scp failed with status: {}", status);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("[WARN] No files found to transfer.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue