Skip to content

Commit

Permalink
fix: creation of parent dir of symlink (prefix-dev#1483)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-arts authored and jjjermiah committed Jun 11, 2024
1 parent b95d571 commit 3f2f4bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ distribution-filename = { git = "https://github.com/astral-sh/uv", rev = "65b17f
distribution-types = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" }
dunce = "1.0.4"
flate2 = "1.0.28"
fs_extra = "1.3.0"
futures = "0.3.30"
http-cache-reqwest = "0.14.0"
human_bytes = "0.4.3"
Expand Down
22 changes: 14 additions & 8 deletions src/project/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,23 +559,29 @@ pub fn find_project_manifest() -> Option<PathBuf> {
})
}

/// Create a symlink from the default pixi directory to the custom target
/// directory
/// Create a symlink from the directory to the custom target directory
#[cfg(not(windows))]
fn create_symlink(pixi_dir_name: &Path, default_pixi_dir: &Path) {
if default_pixi_dir.exists() {
fn create_symlink(target_dir: &Path, symlink_dir: &Path) {
if symlink_dir.exists() {
tracing::debug!(
"Symlink already exists at '{}', skipping creating symlink.",
default_pixi_dir.display()
symlink_dir.display()
);
return;
}
symlink(pixi_dir_name, default_pixi_dir)
let parent = symlink_dir
.parent()
.expect("symlink dir should have parent");
fs_extra::dir::create_all(parent, false)
.map_err(|e| tracing::error!("Failed to create directory '{}': {}", parent.display(), e))
.ok();

symlink(target_dir, symlink_dir)
.map_err(|e| {
tracing::error!(
"Failed to create symlink from '{}' to '{}': {}",
pixi_dir_name.display(),
default_pixi_dir.display(),
target_dir.display(),
symlink_dir.display(),
e
)
})
Expand Down

0 comments on commit 3f2f4bd

Please sign in to comment.