fixed route error

master
Spencer Kohan 4 years ago
parent 435c52ef71
commit cfdb80af14

@ -6,7 +6,9 @@ use serde::{Deserialize, Serialize};
#[derive(Clone)]
pub enum SubCommand {
#[structopt(name="init")]
Init(RemoteConfigRecord)
Init(RemoteConfigRecord),
#[structopt(name="clean")]
Clean,
}
#[derive(Debug)]
@ -37,3 +39,4 @@ pub struct RemoteConfigRecord {
#[structopt(short = "u", long = "user")]
pub user: String,
}

@ -12,6 +12,7 @@ pub enum InitError {
fn create_dirsync_dirs() -> Result<(), std::io::Error> {
fs::create_dir_all("./.dirsync/actions/onSyncDidFinish")?;
fs::create_dir_all("./.dirsync/actions/onSessionDidStart")?;
Ok(())
}

@ -20,12 +20,12 @@ fn rsync(config: &config::SessionConfig) {
use std::process::Command;
// we sync actions explicitly here, since they might be ignored otherwise
let dirsync_dir_local = &format!("{}/.dirsync/actions", &config.local_root);
let dirsync_dir_local = &format!("{}/.dirsync", &config.local_root);
let dirsync_dir_remote = &format!("{}", &config.destination());
let output = &Command::new("rsync")
.arg("-v") // verbose output
.arg("-r")
.arg("-ar")
.arg(dirsync_dir_local)
.arg(dirsync_dir_remote)
.output()
@ -41,7 +41,7 @@ fn rsync(config: &config::SessionConfig) {
let output = &Command::new("rsync")
.arg("-v") // verbose output
.arg("-r")
.arg("-ar")
.arg(format!("--exclude-from={}", config.exclude_path().to_str().unwrap()))
.arg("--exclude-from=.gitignore")
.arg(&config.local_root)
@ -59,7 +59,7 @@ fn rsync(config: &config::SessionConfig) {
let output = &Command::new("rsync")
.arg("-v") // verbose output
.arg("-r")
.arg("-ar")
.arg(format!("--exclude-from={}", config.exclude_path().to_str().unwrap()))
.arg(&config.local_root)
.arg(&config.destination())
@ -92,7 +92,7 @@ fn start_main_loop(config: &SessionConfig) {
rsync(&config);
let mut remote = remote::Remote::connect(config);
remote.execute_if_exists("onSyncDidFinish");
remote.execute_if_exists("onSessionDidStart");
// Create a channel to receive the events.
let (tx, rx) = channel();
@ -124,6 +124,11 @@ fn main() {
match opts.subcommand {
Some(SubCommand::Init(remote_config)) => init::init_dirsync_dir(remote_config).unwrap(),
Some(SubCommand::Clean) => {
let config = SessionConfig::get(opts);
let mut remote = remote::Remote::connect(&config);
remote.remove_dir(config.remote.root.as_str());
},
_ => {
let config = SessionConfig::get(opts);
start_main_loop(&config);

@ -100,4 +100,10 @@ impl Remote {
self.exec_stream(&command2);
}
pub fn remove_dir(&mut self, path: &str) {
let command = &format!("rm -rf {}", path);
let s = self.exec(&command);
print!("clean result: {}\n", s);
}
}
Loading…
Cancel
Save