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 clippy --all-targets --all-features -- -D warnings
|
||||
cargo check
|
||||
cargo check --frozen
|
||||
cargo test
|
||||
cargo test -- --ignored
|
||||
|
|
|
@ -55,7 +55,7 @@ impl Index {
|
|||
fs::create_dir_all(
|
||||
path.as_ref()
|
||||
.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")?;
|
||||
|
||||
|
@ -108,10 +108,7 @@ impl Index {
|
|||
Ok(self
|
||||
.index_file_path()
|
||||
.parent()
|
||||
.ok_or(anyhow!(
|
||||
"cannot compute parent path for {}",
|
||||
self.index_file_path().to_string_lossy()
|
||||
))?
|
||||
.ok_or_else(|| anyhow!("cannot compute parent path for {}", self.index_file_path().to_string_lossy()))?
|
||||
.to_path_buf())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,10 +113,9 @@ impl<'a> Repository<'a> {
|
|||
let destination_path = Path::new(&destination_path);
|
||||
|
||||
if source_path.is_file() {
|
||||
let parent = destination_path.parent().ok_or(anyhow!(
|
||||
"cannot compute parent path for {}",
|
||||
&destination_path.to_string_lossy()
|
||||
))?;
|
||||
let parent = destination_path
|
||||
.parent()
|
||||
.ok_or_else(|| anyhow!("cannot compute parent path for {}", &destination_path.to_string_lossy()))?;
|
||||
fs::create_dir_all(parent)?;
|
||||
fs::copy(source_path, destination_path)?;
|
||||
let relative_path = destination_path.strip_prefix(self.path)?;
|
||||
|
|
|
@ -36,7 +36,7 @@ impl RepositoryItem {
|
|||
}
|
||||
let parent = target_path
|
||||
.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() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue