mirror of
https://github.com/pesde-pkg/pesde.git
synced 2024-12-12 11:00:36 +00:00
fix: correct cas finding algorithm
This commit is contained in:
parent
dca495a467
commit
9f3017742e
2 changed files with 22 additions and 2 deletions
|
@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Use a different algorithm for finding a CAS directory to avoid issues with mounted drives by @daimond113
|
- Use a different algorithm for finding a CAS directory to avoid issues with mounted drives by @daimond113
|
||||||
- Remove default.project.json from Git pesde dependencies by @daimond113
|
- Remove default.project.json from Git pesde dependencies by @daimond113
|
||||||
- Correctly (de)serialize workspace specifiers by @daimond113
|
- Correctly (de)serialize workspace specifiers by @daimond113
|
||||||
|
- Fix CAS finder algorithm issues with Windows by @daimond113
|
||||||
|
- Fix CAS finder algorithm's AlreadyExists error by @daimond113
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Switched to fs-err for better errors with file system operations by @daimond113
|
- Switched to fs-err for better errors with file system operations by @daimond113
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -36,9 +36,27 @@ struct Cli {
|
||||||
async fn get_linkable_dir(path: &Path) -> PathBuf {
|
async fn get_linkable_dir(path: &Path) -> PathBuf {
|
||||||
let mut curr_path = PathBuf::new();
|
let mut curr_path = PathBuf::new();
|
||||||
let file_to_try = NamedTempFile::new_in(path).expect("failed to create temporary file");
|
let file_to_try = NamedTempFile::new_in(path).expect("failed to create temporary file");
|
||||||
let temp_file_name = file_to_try.path().file_name().unwrap();
|
|
||||||
|
|
||||||
for component in path.components() {
|
let temp_path = tempfile::Builder::new()
|
||||||
|
.make(|_| Ok(()))
|
||||||
|
.expect("failed to create temporary file")
|
||||||
|
.into_temp_path();
|
||||||
|
let temp_file_name = temp_path.file_name().expect("failed to get file name");
|
||||||
|
|
||||||
|
// C: and \ are different components on Windows
|
||||||
|
#[cfg(windows)]
|
||||||
|
let components = path.components().map(|c| {
|
||||||
|
let mut path = c.as_os_str().to_os_string();
|
||||||
|
if let std::path::Component::Prefix(_) = c {
|
||||||
|
path.push(std::path::MAIN_SEPARATOR_STR);
|
||||||
|
}
|
||||||
|
|
||||||
|
path
|
||||||
|
});
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
let components = path.components().map(|c| c.as_os_str().to_os_string());
|
||||||
|
|
||||||
|
for component in components {
|
||||||
curr_path.push(component);
|
curr_path.push(component);
|
||||||
|
|
||||||
let try_path = curr_path.join(temp_file_name);
|
let try_path = curr_path.join(temp_file_name);
|
||||||
|
|
Loading…
Reference in a new issue