mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-15 07:06:36 +00:00
Refactor mod crates_manifests to use create_if_not_exist
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
This commit is contained in:
parent
cee14f9288
commit
1f4defe042
1 changed files with 2 additions and 9 deletions
|
@ -12,8 +12,7 @@ use thiserror::Error as ThisError;
|
||||||
use crate::{
|
use crate::{
|
||||||
binstall_crates_v1::{Error as BinstallCratesV1Error, Records as BinstallCratesV1Records},
|
binstall_crates_v1::{Error as BinstallCratesV1Error, Records as BinstallCratesV1Records},
|
||||||
cargo_crates_v1::{CratesToml, CratesTomlParseError},
|
cargo_crates_v1::{CratesToml, CratesTomlParseError},
|
||||||
crate_info::CrateInfo,
|
crate_info::CrateInfo, helpers::create_if_not_exist, CompactString, Version,
|
||||||
CompactString, Version,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, ThisError)]
|
#[derive(Debug, Diagnostic, ThisError)]
|
||||||
|
@ -47,13 +46,7 @@ impl Manifests {
|
||||||
// Read cargo_install_v1_metadata
|
// Read cargo_install_v1_metadata
|
||||||
let manifest_path = cargo_roots.join(".crates.toml");
|
let manifest_path = cargo_roots.join(".crates.toml");
|
||||||
|
|
||||||
let cargo_crates_v1 = fs::File::options()
|
let cargo_crates_v1 = create_file_if_not_exist(manifest_path)?;
|
||||||
.read(true)
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.truncate(false)
|
|
||||||
.open(manifest_path)
|
|
||||||
.and_then(FileLock::new_exclusive)?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
binstall,
|
binstall,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue