|
|
@@ -52,9 +52,7 @@ impl SynchronizedDirectory {
|
|
52
|
52
|
errors: mpsc::Sender<SynchronizationError>,
|
|
53
|
53
|
) -> Result<SynchronizedDirectory, Error> {
|
|
54
|
54
|
// TODO: First, connect to the server and test whether we can access the URL?
|
|
55
|
|
- // At this point, the directory is still paused.
|
|
56
|
|
- // TODO: Return an error if the directory is not empty (unless the user specified an
|
|
57
|
|
- // override option).
|
|
|
55
|
+ // Probably not possible, at this point the directory is still paused.
|
|
58
|
56
|
let file_tree = Arc::new(Mutex::new(FileTree::create(
|
|
59
|
57
|
database, directory, remote_url,
|
|
60
|
58
|
)?));
|
|
|
@@ -157,7 +155,7 @@ async fn main() {
|
|
157
|
155
|
stream.write_all(&(-1i32).to_be_bytes()).await.ok();
|
|
158
|
156
|
stream.write_all(&output).await.ok();
|
|
159
|
157
|
stream
|
|
160
|
|
- .write_all(format!("Error: {:?}", e).as_bytes())
|
|
|
158
|
+ .write_all(format!("Error: {}\n", e).as_bytes())
|
|
161
|
159
|
.await
|
|
162
|
160
|
.ok();
|
|
163
|
161
|
}
|
|
|
@@ -239,7 +237,19 @@ async fn handle_cli_client(
|
|
239
|
237
|
cli::Command::AddDirectory {
|
|
240
|
238
|
local_directory,
|
|
241
|
239
|
remote_url,
|
|
|
240
|
+ force,
|
|
242
|
241
|
} => {
|
|
|
242
|
+ if !local_directory.exists() || !local_directory.is_dir() {
|
|
|
243
|
+ return Err(Error::InvalidParam(
|
|
|
244
|
+ "the specified local path does not exist or is no directory".to_owned(),
|
|
|
245
|
+ ));
|
|
|
246
|
+ }
|
|
|
247
|
+ if local_directory.read_dir()?.next().is_some() && !force {
|
|
|
248
|
+ return Err(Error::InvalidParam(
|
|
|
249
|
+ "the specified local directory is not empty (use --force to add the directory)"
|
|
|
250
|
+ .to_owned(),
|
|
|
251
|
+ ));
|
|
|
252
|
+ }
|
|
243
|
253
|
let local_directory = fs::canonicalize(local_directory)?;
|
|
244
|
254
|
// We need to check that we are not synchronizing directories that are within
|
|
245
|
255
|
// other synchronized directories.
|