Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consistent clobbering & removal of __pycache__ #437

Merged
merged 10 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 13 additions & 28 deletions crates/rattler-bin/src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ use futures::{stream, stream::FuturesUnordered, FutureExt, StreamExt, TryFutureE
use indicatif::{HumanBytes, ProgressBar, ProgressState, ProgressStyle};
use rattler::{
default_cache_dir,
install::{link_package, InstallDriver, InstallOptions, Transaction, TransactionOperation},
install::{
link_package, unlink_package, InstallDriver, InstallOptions, Transaction,
TransactionOperation,
},
package_cache::PackageCache,
};
use rattler_conda_types::{
Expand All @@ -25,7 +28,6 @@ use std::{
env,
fmt::Write,
future::ready,
io::ErrorKind,
path::{Path, PathBuf},
str::FromStr,
time::Duration,
Expand Down Expand Up @@ -367,6 +369,14 @@ async fn execute_transaction(
})
.await?;

// Perform any post processing that is required.
let prefix_records = find_installed_packages(&target_prefix, 100)
.await
.context("failed to determine currently installed packages")?;
install_driver
.post_process(&prefix_records, &target_prefix)
.expect("bla");

Ok(())
}

Expand Down Expand Up @@ -520,32 +530,7 @@ async fn remove_package_from_environment(
target_prefix: &Path,
package: &PrefixRecord,
) -> anyhow::Result<()> {
// TODO: Take into account any clobbered files, they need to be restored.
// TODO: Can we also delete empty directories?

// Remove all entries
for paths in package.paths_data.paths.iter() {
match tokio::fs::remove_file(target_prefix.join(&paths.relative_path)).await {
Ok(_) => {}
Err(e) if e.kind() == ErrorKind::NotFound => {
// Simply ignore if the file is already gone.
}
Err(e) => {
return Err(e)
.with_context(|| format!("failed to delete {}", paths.relative_path.display()))
}
}
}

// Remove the conda-meta file
let conda_meta_path = target_prefix.join("conda-meta").join(format!(
"{}-{}-{}.json",
package.repodata_record.package_record.name.as_normalized(),
package.repodata_record.package_record.version,
package.repodata_record.package_record.build
));
tokio::fs::remove_file(conda_meta_path).await?;

unlink_package(target_prefix, package).await?;
Ok(())
}

Expand Down
2 changes: 2 additions & 0 deletions crates/rattler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ bytes = "1.5.0"
chrono = { version = "0.4.31", default-features = false, features = ["std", "serde", "alloc"] }
digest = "0.10.7"
dirs = "5.0.1"
drop_bomb = "0.1.5"
futures = "0.3.28"
fxhash = "0.2.1"
hex = "0.4.3"
indexmap = "2.1.0"
itertools = "0.11.0"
memchr = "2.6.4"
memmap2 = "0.7.1"
Expand Down
Loading