Skip to content

Commit

Permalink
fix: skip lockfile methods when experimental is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Nov 21, 2024
1 parent b747205 commit 4b1fa10
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct LockfileTool {
}

impl Lockfile {
pub fn read<P: AsRef<Path>>(path: P) -> Result<Self> {
fn read<P: AsRef<Path>>(path: P) -> Result<Self> {
trace!("reading lockfile {}", display_path(&path));
let content = file::read_to_string(path)?;
let mut table: toml::Table = toml::from_str(&content)?;
Expand All @@ -47,8 +47,7 @@ impl Lockfile {
Ok(lockfile)
}

pub fn save<P: AsRef<Path>>(&self, path: P) -> Result<()> {
SETTINGS.ensure_experimental("lockfile")?;
fn save<P: AsRef<Path>>(&self, path: P) -> Result<()> {
if self.is_empty() {
let _ = file::remove_file(path);
} else {
Expand All @@ -74,7 +73,7 @@ impl Lockfile {
Ok(())
}

pub fn is_empty(&self) -> bool {
fn is_empty(&self) -> bool {
self.tools.is_empty()
}
}
Expand All @@ -83,7 +82,6 @@ pub fn update_lockfiles(new_versions: &[ToolVersion]) -> Result<()> {
if !SETTINGS.lockfile || !SETTINGS.experimental {
return Ok(());
}
SETTINGS.ensure_experimental("lockfile")?;
let config = Config::load()?;
let ts = ToolsetBuilder::new().build(&config)?;
let mut all_tool_names = HashSet::new();
Expand Down Expand Up @@ -185,10 +183,9 @@ pub fn get_locked_version(
short: &str,
prefix: &str,
) -> Result<Option<LockfileTool>> {
if !SETTINGS.lockfile {
if !SETTINGS.lockfile || !SETTINGS.experimental {
return Ok(None);
}
SETTINGS.ensure_experimental("lockfile")?;

let lockfile = match path {
Some(path) => {
Expand Down

0 comments on commit 4b1fa10

Please sign in to comment.