Optionally run rsync

master
Paul van Tilburg 4 years ago
parent 9967932881
commit 52c2fc7bb4
  1. 21
      src/main.rs

@ -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();
}