fix: uvx and npx dirs should be not be relocated

This commit is contained in:
Louis 2025-08-11 14:18:27 +07:00
parent b924156a15
commit f3dd26e499
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
3 changed files with 12 additions and 5 deletions

View File

@ -134,7 +134,7 @@ jobs:
test-on-windows-pr:
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) && 'windows-latest' || 'WINDOWS-11' }}
runs-on: 'windows-latest'
steps:
- name: Getting the repo
uses: actions/checkout@v3

View File

@ -303,8 +303,8 @@ pub fn get_user_home_path(app: AppHandle) -> String {
return get_app_configurations(app.clone()).data_folder;
}
/// Recursively copy a directory from src to dst
fn copy_dir_recursive(src: &PathBuf, dst: &PathBuf) -> Result<(), io::Error> {
/// Recursively copy a directory from src to dst, excluding specified directories
fn copy_dir_recursive(src: &PathBuf, dst: &PathBuf, exclude_dirs: &[&str]) -> Result<(), io::Error> {
if !dst.exists() {
fs::create_dir_all(dst)?;
}
@ -316,7 +316,13 @@ fn copy_dir_recursive(src: &PathBuf, dst: &PathBuf) -> Result<(), io::Error> {
let dst_path = dst.join(entry.file_name());
if file_type.is_dir() {
copy_dir_recursive(&src_path, &dst_path)?;
// Skip excluded directories
if let Some(dir_name) = entry.file_name().to_str() {
if exclude_dirs.contains(&dir_name) {
continue;
}
}
copy_dir_recursive(&src_path, &dst_path, exclude_dirs)?;
} else {
fs::copy(&src_path, &dst_path)?;
}
@ -354,7 +360,7 @@ pub fn change_app_data_folder(
"New data folder cannot be a subdirectory of the current data folder".to_string(),
);
}
copy_dir_recursive(&current_data_folder, &new_data_folder_path)
copy_dir_recursive(&current_data_folder, &new_data_folder_path, &[".uvx", ".npx"])
.map_err(|e| format!("Failed to copy data to new folder: {}", e))?;
} else {
log::info!("Current data folder does not exist, nothing to copy");

View File

@ -173,6 +173,7 @@ function General() {
setSelectedNewPath(null)
setIsDialogOpen(false)
} catch (error) {
console.error(error)
toast.error(
error instanceof Error
? error.message