Optionally run rsync
This commit is contained in:
parent
9967932881
commit
52c2fc7bb4
21
src/main.rs
21
src/main.rs
|
@ -14,7 +14,9 @@ use cursive::views::{Checkbox, Dialog, ListView, ProgressBar, TextView};
|
||||||
use cursive::Cursive;
|
use cursive::Cursive;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
use std::os::unix::process::CommandExt;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::Command;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use registry::Registry;
|
use registry::Registry;
|
||||||
|
@ -145,10 +147,27 @@ fn save_albums(ui: &mut Cursive) {
|
||||||
|
|
||||||
ui.pop_layer();
|
ui.pop_layer();
|
||||||
ui.add_layer(
|
ui.add_layer(
|
||||||
Dialog::around(TextView::new("All albums have been saved!")).button("Ok", |ui| ui.quit()),
|
Dialog::around(TextView::new("All albums have been saved!\nSynchronise?"))
|
||||||
|
.button("Yes", |ui| sync_albums(ui))
|
||||||
|
.button("No", |ui| ui.quit()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn sync_albums(ui: &mut Cursive) {
|
||||||
|
let registry = REGISTRY.lock().unwrap();
|
||||||
|
ui.quit();
|
||||||
|
|
||||||
|
Command::new("echo")
|
||||||
|
.arg("rsync")
|
||||||
|
.arg("-vaP")
|
||||||
|
.arg(&format!("--include-from={}.list.new", registry.device))
|
||||||
|
.arg("--exclude=\"*\"")
|
||||||
|
.arg("--delete")
|
||||||
|
.arg(®istry.base_path)
|
||||||
|
.arg("target_path")
|
||||||
|
.exec();
|
||||||
|
}
|
||||||
|
|
||||||
fn quit(ui: &mut Cursive) {
|
fn quit(ui: &mut Cursive) {
|
||||||
ui.quit();
|
ui.quit();
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue