Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: uvx and npx dirs should be not be relocated

Louisf3dd26e499e0
diff --git a/.github/workflows/jan-linter-and-test.yml b/.github/workflows/jan-linter-and-test.yml
index e2f437837..cfcfe78ed 100644
--- a/.github/workflows/jan-linter-and-test.yml
+++ b/.github/workflows/jan-linter-and-test.yml
@@ -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
diff --git a/src-tauri/src/core/cmd.rs b/src-tauri/src/core/cmd.rs
index 2ebe031f1..37937cfe0 100644
--- a/src-tauri/src/core/cmd.rs
+++ b/src-tauri/src/core/cmd.rs
@@ -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");
diff --git a/web-app/src/routes/settings/general.tsx b/web-app/src/routes/settings/general.tsx
index a5ce5ec26..ab19deccf 100644
--- a/web-app/src/routes/settings/general.tsx
+++ b/web-app/src/routes/settings/general.tsx
@@ -173,6 +173,7 @@ function General() {
setSelectedNewPath(null)
setIsDialogOpen(false)
} catch (error) {
+ console.error(error)
toast.error(
error instanceof Error
? error.message