fix(data): fix data directory errors and log display issues

This commit is contained in:
Suyunmeng
2025-11-08 09:53:57 +08:00
parent 4c76f31885
commit e4ab2184eb
4 changed files with 879 additions and 906 deletions

View File

@@ -225,18 +225,17 @@ jobs:
- name: Build the app
if: matrix.platform == 'windows' || matrix.platform == 'linux'
run: |
yarn build --target ${{ matrix.target }}
uses: tauri-apps/tauri-action@v0
env:
NODE_OPTIONS: "--max_old_space_size=4096"
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
args: --target ${{ matrix.target }}
- name: Build the app (macOS)
uses: tauri-apps/tauri-action@v0
if: matrix.platform == 'macos'
run: |
export TAURI_SKIP_SIDECAR_SIGNATURE_CHECK=true
yarn build --target ${{ matrix.target }}
env:
NODE_OPTIONS: "--max_old_space_size=4096"
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
@@ -248,6 +247,9 @@ jobs:
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
TAURI_SKIP_SIDECAR_SIGNATURE_CHECK: "true"
with:
args: --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v4

View File

@@ -98,8 +98,11 @@
"tar": "^7.4.3",
"typescript": "^5.8.3",
"typescript-eslint": "^8.41.0",
"vite": "^7.1.3",
"vite": "^7.1.11",
"vue-eslint-parser": "^10.2.0",
"vue-tsc": "^3.0.6"
},
"overrides": {
"tmp": "^0.2.4"
}
}

View File

@@ -3,6 +3,31 @@ use std::{env, fs};
pub static APP_ID: &str = "io.github.openlistteam.openlist.desktop";
// Normalize path without Windows long path prefix (\\?\)
// The \\?\ prefix breaks compatibility with some applications like SQLite
fn normalize_path(path: &PathBuf) -> Result<PathBuf, String> {
#[cfg(target_os = "windows")]
{
// On Windows, use canonicalize but strip the \\?\ prefix if present
let canonical = path
.canonicalize()
.map_err(|e| format!("Failed to canonicalize path: {e}"))?;
let path_str = canonical.to_string_lossy();
if let Some(stripped) = path_str.strip_prefix(r"\\?\") {
Ok(PathBuf::from(stripped))
} else {
Ok(canonical)
}
}
#[cfg(not(target_os = "windows"))]
{
path.canonicalize()
.map_err(|e| format!("Failed to canonicalize path: {e}"))
}
}
fn get_app_dir() -> Result<PathBuf, String> {
let app_dir = env::current_exe()
.map_err(|e| format!("Failed to get current exe path: {e}"))?
@@ -46,9 +71,7 @@ fn get_user_data_dir() -> Result<PathBuf, String> {
fs::create_dir_all(&data_dir).map_err(|e| format!("Failed to create data directory: {e}"))?;
data_dir
.canonicalize()
.map_err(|e| format!("Failed to canonicalize data directory: {e}"))
normalize_path(&data_dir)
}
fn get_user_logs_dir() -> Result<PathBuf, String> {
@@ -69,9 +92,7 @@ fn get_user_logs_dir() -> Result<PathBuf, String> {
};
fs::create_dir_all(&logs_dir).map_err(|e| format!("Failed to create logs directory: {e}"))?;
logs_dir
.canonicalize()
.map_err(|e| format!("Failed to canonicalize logs directory: {e}"))
normalize_path(&logs_dir)
}
fn get_binary_path(binary: &str, service_name: &str) -> Result<PathBuf, String> {
@@ -123,16 +144,14 @@ pub fn get_service_log_path() -> Result<PathBuf, String> {
let home = env::var("HOME").map_err(|_| "Failed to get HOME environment variable")?;
let logs = PathBuf::from(home)
.join("Library")
.join("Application Support")
.join("io.github.openlistteam.openlist.service.bundle")
.join("Contents")
.join("MacOS")
.join("Logs")
.join("OpenList Desktop")
.join("openlist-desktop-service.log");
Ok(logs)
}
#[cfg(not(target_os = "macos"))]
{
Ok(get_user_data_dir()?.join("openlist-desktop-service.log"))
Ok(get_app_logs_dir()?.join("openlist-desktop-service.log"))
}
}

1727
yarn.lock

File diff suppressed because it is too large Load Diff