Skip to content

Commit a336d0a

Browse files
committed
fix convert_file_src + build
1 parent ee0f36f commit a336d0a

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

.github/workflows/android-split.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ jobs:
6161
- name: Install dependencies
6262
run: bun install
6363

64+
- name: Clean Output Directory
65+
run: |
66+
OUTPUT_DIR=src-tauri/gen/android/app/build/outputs/apk/universal/renamed
67+
rm -rf "$OUTPUT_DIR"
68+
6469
- name: Build split-ABI APKs
6570
run: bun tauri android build --apk --split-per-abi
6671

.github/workflows/android-universal.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ jobs:
6060
6161
- name: Install dependencies
6262
run: bun install
63+
64+
- name: Clean Output Directory
65+
run: |
66+
OUTPUT_DIR=src-tauri/gen/android/app/build/outputs/apk/universal/renamed
67+
rm -rf "$OUTPUT_DIR"
6368
6469
- name: Build universal APK
6570
run: bun tauri android build

.github/workflows/windows.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ jobs:
3535
- name: Install dependencies
3636
run: bun install
3737

38+
- name: Clean NSIS output folder
39+
shell: pwsh
40+
run: |
41+
$nsisPath = "src-tauri/target/release/bundle/nsis"
42+
if (Test-Path $nsisPath) {
43+
Remove-Item -Recurse -Force $nsisPath
44+
}
45+
46+
3847
- name: Build Windows installer
3948
run: bun tauri build
4049

src-tauri/src/utils/convert_file_src.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,26 @@ use std::path::PathBuf;
33
pub fn new(file_path: &PathBuf) -> Result<String, String> {
44
#[cfg(any(windows, target_os = "android"))]
55
let base = "http://asset.localhost/";
6+
67
#[cfg(not(any(windows, target_os = "android")))]
78
let base = "asset://localhost/";
89

9-
let path = dunce::canonicalize(file_path).map_err(|e| e.to_string())?;
10-
let path_to_string = path.display().to_string();
11-
let encoded = urlencoding::encode(&path_to_string);
10+
// Windows/Android: canonicalize for absolute path resolution
11+
#[cfg(any(windows, target_os = "android"))]
12+
let path_str = {
13+
let path = dunce::canonicalize(file_path).map_err(|e| e.to_string())?;
14+
path.display().to_string()
15+
};
16+
17+
// Linux/macOS: use raw path, strip leading slash
18+
#[cfg(not(any(windows, target_os = "android")))]
19+
let path_str = {
20+
let raw = file_path.display().to_string();
21+
raw.trim_start_matches('/').to_string()
22+
};
1223

24+
let encoded = urlencoding::encode(&path_str);
1325
let url = format!("{base}{encoded}");
1426

15-
return Ok(url);
27+
Ok(url)
1628
}

0 commit comments

Comments
 (0)