aboutsummaryrefslogtreecommitdiff
path: root/src/remote
diff options
context:
space:
mode:
Diffstat (limited to 'src/remote')
-rw-r--r--src/remote/git.rs8
-rw-r--r--src/remote/mod.rs12
2 files changed, 9 insertions, 11 deletions
diff --git a/src/remote/git.rs b/src/remote/git.rs
index 3290793..c8aaf46 100644
--- a/src/remote/git.rs
+++ b/src/remote/git.rs
@@ -1,4 +1,4 @@
-use std::io::{Error, ErrorKind::Other, Result};
+use std::io::{Error, Result};
use std::path::Path;
use std::process::{Command, Stdio};
use std::time::{SystemTime, UNIX_EPOCH};
@@ -27,7 +27,7 @@ impl super::Remote for Git {
fn sync_up(&self, remote: &str, directory: &Path) -> Result<()> {
let timestamp = SystemTime::now()
.duration_since(UNIX_EPOCH)
- .map_err(|_| Error::new(Other, "Invalid time"))?
+ .map_err(|_| Error::other("Invalid time"))?
.as_millis();
let commit_name = format!("blog-sync-up-{timestamp}");
@@ -45,7 +45,7 @@ impl super::Remote for Git {
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
- .map_err(|_| Error::new(Other, "Failed while performing sync up with git"))?;
+ .map_err(|_| Error::other("Failed while performing sync up with git"))?;
}
Ok(())
@@ -66,7 +66,7 @@ impl super::Remote for Git {
.stdout(Stdio::null())
.stderr(Stdio::null())
.status()
- .map_err(|_| Error::new(Other, "Failed while performing sync down with git"))?;
+ .map_err(|_| Error::other("Failed while performing sync down with git"))?;
}
Ok(())
}
diff --git a/src/remote/mod.rs b/src/remote/mod.rs
index 90f400c..5fc73cc 100644
--- a/src/remote/mod.rs
+++ b/src/remote/mod.rs
@@ -1,7 +1,7 @@
mod git;
use std::fs::{File, create_dir_all, remove_file, write};
-use std::io::{Error, ErrorKind::Other, Read, Result};
+use std::io::{Error, Read, Result};
use std::path::Path;
use git::Git;
@@ -27,7 +27,7 @@ pub fn remove(remote_config: &Path) -> Result<()> {
pub fn sync_up(data_directory: &Path, remote_config: &Path) -> Result<()> {
let remote_address =
- read_remote(remote_config).ok_or_else(|| Error::new(Other, "No remote is configured"))?;
+ read_remote(remote_config).ok_or_else(|| Error::other("No remote is configured"))?;
create_dir_all(data_directory)?;
let remotes = available_remotes();
for remote in remotes {
@@ -35,15 +35,14 @@ pub fn sync_up(data_directory: &Path, remote_config: &Path) -> Result<()> {
return remote.sync_up(&remote_address, data_directory);
}
}
- Err(Error::new(
- Other,
+ Err(Error::other(
"No valid strategies found for your configured remote.",
))
}
pub fn sync_down(data_directory: &Path, remote_config: &Path) -> Result<()> {
let remote_address =
- read_remote(remote_config).ok_or_else(|| Error::new(Other, "No remote is configured"))?;
+ read_remote(remote_config).ok_or_else(|| Error::other("No remote is configured"))?;
create_dir_all(data_directory)?;
let remotes = available_remotes();
for remote in remotes {
@@ -51,8 +50,7 @@ pub fn sync_down(data_directory: &Path, remote_config: &Path) -> Result<()> {
return remote.sync_down(&remote_address, data_directory);
}
}
- Err(Error::new(
- Other,
+ Err(Error::other(
"No valid strategies found for your configured remote.",
))
}