stronger checks
This commit is contained in:
parent
d706826279
commit
de6705c0fc
4 changed files with 7 additions and 11 deletions
|
@ -7,6 +7,6 @@ fi
|
||||||
|
|
||||||
cargo fmt -- --check
|
cargo fmt -- --check
|
||||||
cargo clippy --all-targets --all-features -- -D warnings
|
cargo clippy --all-targets --all-features -- -D warnings
|
||||||
cargo check
|
cargo check --frozen
|
||||||
cargo test
|
cargo test
|
||||||
cargo test -- --ignored
|
cargo test -- --ignored
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl Index {
|
||||||
fs::create_dir_all(
|
fs::create_dir_all(
|
||||||
path.as_ref()
|
path.as_ref()
|
||||||
.parent()
|
.parent()
|
||||||
.ok_or(anyhow!("cannot compute parent path for {}", path.as_ref().to_string_lossy()))?,
|
.ok_or_else(|| anyhow!("cannot compute parent path for {}", path.as_ref().to_string_lossy()))?,
|
||||||
)
|
)
|
||||||
.context("create index directory")?;
|
.context("create index directory")?;
|
||||||
|
|
||||||
|
@ -108,10 +108,7 @@ impl Index {
|
||||||
Ok(self
|
Ok(self
|
||||||
.index_file_path()
|
.index_file_path()
|
||||||
.parent()
|
.parent()
|
||||||
.ok_or(anyhow!(
|
.ok_or_else(|| anyhow!("cannot compute parent path for {}", self.index_file_path().to_string_lossy()))?
|
||||||
"cannot compute parent path for {}",
|
|
||||||
self.index_file_path().to_string_lossy()
|
|
||||||
))?
|
|
||||||
.to_path_buf())
|
.to_path_buf())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,10 +113,9 @@ impl<'a> Repository<'a> {
|
||||||
let destination_path = Path::new(&destination_path);
|
let destination_path = Path::new(&destination_path);
|
||||||
|
|
||||||
if source_path.is_file() {
|
if source_path.is_file() {
|
||||||
let parent = destination_path.parent().ok_or(anyhow!(
|
let parent = destination_path
|
||||||
"cannot compute parent path for {}",
|
.parent()
|
||||||
&destination_path.to_string_lossy()
|
.ok_or_else(|| anyhow!("cannot compute parent path for {}", &destination_path.to_string_lossy()))?;
|
||||||
))?;
|
|
||||||
fs::create_dir_all(parent)?;
|
fs::create_dir_all(parent)?;
|
||||||
fs::copy(source_path, destination_path)?;
|
fs::copy(source_path, destination_path)?;
|
||||||
let relative_path = destination_path.strip_prefix(self.path)?;
|
let relative_path = destination_path.strip_prefix(self.path)?;
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl RepositoryItem {
|
||||||
}
|
}
|
||||||
let parent = target_path
|
let parent = target_path
|
||||||
.parent()
|
.parent()
|
||||||
.ok_or(anyhow!("cannot compute parent path for {}", &target_path.to_string_lossy()))?;
|
.ok_or_else(|| anyhow!("cannot compute parent path for {}", &target_path.to_string_lossy()))?;
|
||||||
if !parent.exists() {
|
if !parent.exists() {
|
||||||
fs::create_dir_all(parent)?;
|
fs::create_dir_all(parent)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue