]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/sync_down.rs
Allow sync up and down
[rbdr/blog] / src / command / sync_down.rs
index dc4114e8d31f0836a047b5fbc76c1bb6127e422c..bba34b29a0837a1e01086dd82186986e64995a97 100644 (file)
@@ -1,6 +1,6 @@
-use std::fs::create_dir_all;
-use std::io::{Result, Error};
+use std::io::{Result};
 use crate::configuration::Configuration;
+use crate::remote::sync_down;
 
 pub struct SyncDown;
 
@@ -16,16 +16,10 @@ impl super::Command for SyncDown {
     }
 
     fn execute(&self, _: Option<&String>, configuration: &Configuration, command: &String) -> Result<()> {
-        match create_dir_all(&configuration.data_directory) {
-            Ok(_) => {
-                // We only care to show these warnings if this is the primary command.
-                if command == self.command() {
-                    println!("WARNING: Sync Down Not yet implemented");
-                }
-                return Ok(())
-            },
-            Err(e) => Err(Error::new(e.kind(), format!("Could not create data directory")))
+        if command == self.command() {
+            return sync_down(&configuration.data_directory, &configuration.remote_config);
         }
+        return Ok(())
     }
 
     fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {