Skip to content

Commit

Permalink
fixed bug on showing wrong error if config was incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-eth committed Aug 24, 2024
1 parent a6bd9c4 commit 3ed6dc6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/janitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ pub fn cleanup_dependency(dependency: &Dependency, full: bool) -> Result<()> {
sanitize_dependency_name(&format!("{}-{}", dependency.name(), dependency.version()));

let new_path = DEPENDENCY_DIR.clone().join(format!("{sanitized_name}.zip"));
if let Dependency::Http(_) = dependency {
if new_path.exists() {
fs::remove_file(&new_path)
.map_err(|e| JanitorError::IOError { path: new_path, source: e })?;
}
if full {
let dir = DEPENDENCY_DIR.join(sanitized_name);
fs::remove_dir_all(&dir).map_err(|e| JanitorError::IOError { path: dir, source: e })?;
if dir.exists() {
fs::remove_dir_all(&dir).map_err(|e| JanitorError::IOError { path: dir, source: e })?;
}
remove_lock(dependency).map_err(JanitorError::LockError)?;
}
Ok(())
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ pub async fn run(command: Subcommands) -> Result<(), SoldeerError> {
Subcommands::Install(install) => {
let regenerate_remappings = install.regenerate_remappings;
let Some(dependency) = install.dependency else {
return update(regenerate_remappings, install.recursive_deps).await; // TODO: instead, check which
// dependencies
// do
// not match the
// integrity checksum and install those
return update(regenerate_remappings, install.recursive_deps).await;
// TODO: instead, check which
// dependencies
// do
// not match the
// integrity checksum and install those
};

println!("{}", "🦌 Running Soldeer install 🦌".green());
Expand Down
4 changes: 4 additions & 0 deletions src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ pub fn remove_lock(dependency: &Dependency) -> Result<()> {
} else {
LOCK_FILE.clone()
};
// check if the lock exists, if does not we don't have what to delete
if !lock_file.exists() {
return Ok(());
}

let entries: Vec<_> = read_lock()?
.into_iter()
Expand Down

0 comments on commit 3ed6dc6

Please sign in to comment.