]> git.r.bdr.sh - rbdr/blog/blobdiff - src/command/sync_down.rs
Use sequence format for deb
[rbdr/blog] / src / command / sync_down.rs
index dc4114e8d31f0836a047b5fbc76c1bb6127e422c..eb8e57afdf0b01c0b9b28cedb76eb0541608e922 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,15 @@ 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.
+        match sync_down(&configuration.data_directory, &configuration.remote_config) {
+            Ok(_) => {}
+            Err(e) => {
                 if command == self.command() {
-                    println!("WARNING: Sync Down Not yet implemented");
+                    return Err(e)
                 }
-                return Ok(())
-            },
-            Err(e) => Err(Error::new(e.kind(), format!("Could not create data directory")))
+            }
         }
+        return Ok(())
     }
 
     fn after_dependencies(&self) -> Vec<Box<dyn super::Command>> {