Optionally run rsync

This commit is contained in:
Paul van Tilburg 2018-10-31 19:31:38 +01:00
parent 9967932881
commit 52c2fc7bb4
1 changed files with 20 additions and 1 deletions

View File

@ -14,7 +14,9 @@ use cursive::views::{Checkbox, Dialog, ListView, ProgressBar, TextView};
use cursive::Cursive;
use failure::Error;
use std::ffi::OsStr;
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::Command;
use std::sync::{Arc, Mutex};
use registry::Registry;
@ -145,10 +147,27 @@ fn save_albums(ui: &mut Cursive) {
ui.pop_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(&registry.base_path)
.arg("target_path")
.exec();
}
fn quit(ui: &mut Cursive) {
ui.quit();
}