mirror of
https://github.com/OpenListTeam/OpenList-Desktop.git
synced 2025-11-25 03:14:56 +08:00
fix(data): fix data directory errors and log display issues
This commit is contained in:
12
.github/workflows/build-test.yml
vendored
12
.github/workflows/build-test.yml
vendored
@@ -225,18 +225,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Build the app
|
- name: Build the app
|
||||||
if: matrix.platform == 'windows' || matrix.platform == 'linux'
|
if: matrix.platform == 'windows' || matrix.platform == 'linux'
|
||||||
run: |
|
uses: tauri-apps/tauri-action@v0
|
||||||
yarn build --target ${{ matrix.target }}
|
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
|
||||||
|
with:
|
||||||
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Build the app (macOS)
|
- name: Build the app (macOS)
|
||||||
|
uses: tauri-apps/tauri-action@v0
|
||||||
if: matrix.platform == 'macos'
|
if: matrix.platform == 'macos'
|
||||||
run: |
|
|
||||||
export TAURI_SKIP_SIDECAR_SIGNATURE_CHECK=true
|
|
||||||
yarn build --target ${{ matrix.target }}
|
|
||||||
env:
|
env:
|
||||||
NODE_OPTIONS: "--max_old_space_size=4096"
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
||||||
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
|
||||||
@@ -248,6 +247,9 @@ jobs:
|
|||||||
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
|
||||||
|
TAURI_SKIP_SIDECAR_SIGNATURE_CHECK: "true"
|
||||||
|
with:
|
||||||
|
args: --target ${{ matrix.target }}
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
@@ -98,8 +98,11 @@
|
|||||||
"tar": "^7.4.3",
|
"tar": "^7.4.3",
|
||||||
"typescript": "^5.8.3",
|
"typescript": "^5.8.3",
|
||||||
"typescript-eslint": "^8.41.0",
|
"typescript-eslint": "^8.41.0",
|
||||||
"vite": "^7.1.3",
|
"vite": "^7.1.11",
|
||||||
"vue-eslint-parser": "^10.2.0",
|
"vue-eslint-parser": "^10.2.0",
|
||||||
"vue-tsc": "^3.0.6"
|
"vue-tsc": "^3.0.6"
|
||||||
|
},
|
||||||
|
"overrides": {
|
||||||
|
"tmp": "^0.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,31 @@ use std::{env, fs};
|
|||||||
|
|
||||||
pub static APP_ID: &str = "io.github.openlistteam.openlist.desktop";
|
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> {
|
fn get_app_dir() -> Result<PathBuf, String> {
|
||||||
let app_dir = env::current_exe()
|
let app_dir = env::current_exe()
|
||||||
.map_err(|e| format!("Failed to get current exe path: {e}"))?
|
.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}"))?;
|
fs::create_dir_all(&data_dir).map_err(|e| format!("Failed to create data directory: {e}"))?;
|
||||||
|
|
||||||
data_dir
|
normalize_path(&data_dir)
|
||||||
.canonicalize()
|
|
||||||
.map_err(|e| format!("Failed to canonicalize data directory: {e}"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_user_logs_dir() -> Result<PathBuf, String> {
|
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}"))?;
|
fs::create_dir_all(&logs_dir).map_err(|e| format!("Failed to create logs directory: {e}"))?;
|
||||||
logs_dir
|
normalize_path(&logs_dir)
|
||||||
.canonicalize()
|
|
||||||
.map_err(|e| format!("Failed to canonicalize logs directory: {e}"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_binary_path(binary: &str, service_name: &str) -> Result<PathBuf, String> {
|
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 home = env::var("HOME").map_err(|_| "Failed to get HOME environment variable")?;
|
||||||
let logs = PathBuf::from(home)
|
let logs = PathBuf::from(home)
|
||||||
.join("Library")
|
.join("Library")
|
||||||
.join("Application Support")
|
.join("Logs")
|
||||||
.join("io.github.openlistteam.openlist.service.bundle")
|
.join("OpenList Desktop")
|
||||||
.join("Contents")
|
|
||||||
.join("MacOS")
|
|
||||||
.join("openlist-desktop-service.log");
|
.join("openlist-desktop-service.log");
|
||||||
Ok(logs)
|
Ok(logs)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[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"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user