Skip to content

Commit

Permalink
Fallback to copy dir contents if no windows privileges.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0der committed Jul 17, 2023
1 parent 71ee7b4 commit 9323a34
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bin/default/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Parser;
use colored::Colorize;
use std::fs::remove_dir_all;
use std::fs::{copy, remove_dir_all};
use symlink::{remove_symlink_dir, symlink_dir};

use sdkman_cli_native::constants::{CANDIDATES_DIR, CURRENT_DIR};
Expand Down Expand Up @@ -40,7 +40,7 @@ fn main() {
))
})
}
symlink_dir(version_path, current_link_path)
symlink_dir(version_path.to_owned(), current_link_path.to_owned())
.map(|_| {
println!(
"set {} {} as {} version",
Expand All @@ -49,5 +49,7 @@ fn main() {
"default".italic()
)
})
.expect("cannot create symlink");
.unwrap_or_else(|_| {
copy(version_path, current_link_path).expect("cannot copy directory");
})
}

0 comments on commit 9323a34

Please sign in to comment.