Enable CUDA for Windows/Linux builds + clean up old sidecars
- Windows and Linux sidecar builds now use --with-cuda for GPU acceleration (macOS stays CPU-only — Apple Silicon uses Metal, not CUDA) - Windows upload switched from --data-binary to -T streaming for 2GB+ files - Add cleanup_old_sidecars() that removes stale sidecar-* directories on startup, keeping only the current version - Add NSIS uninstall hook to remove sidecar data dir on Windows uninstall (user data in ~/.voicetonotes is preserved) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -114,7 +114,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build sidecar
|
- name: Build sidecar
|
||||||
working-directory: python
|
working-directory: python
|
||||||
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --with-cuda
|
||||||
|
|
||||||
- name: Package sidecar for Tauri
|
- name: Package sidecar for Tauri
|
||||||
run: |
|
run: |
|
||||||
@@ -217,7 +217,7 @@ jobs:
|
|||||||
- name: Build sidecar
|
- name: Build sidecar
|
||||||
shell: powershell
|
shell: powershell
|
||||||
working-directory: python
|
working-directory: python
|
||||||
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only
|
run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --with-cuda
|
||||||
|
|
||||||
- name: Package sidecar for Tauri
|
- name: Package sidecar for Tauri
|
||||||
shell: powershell
|
shell: powershell
|
||||||
@@ -286,7 +286,7 @@ jobs:
|
|||||||
-X POST `
|
-X POST `
|
||||||
-H "Authorization: token $env:BUILD_TOKEN" `
|
-H "Authorization: token $env:BUILD_TOKEN" `
|
||||||
-H "Content-Type: application/octet-stream" `
|
-H "Content-Type: application/octet-stream" `
|
||||||
--data-binary "@$($_.FullName)" `
|
-T "$($_.FullName)" `
|
||||||
"$uploadUrl" 2>&1
|
"$uploadUrl" 2>&1
|
||||||
if ($LASTEXITCODE -eq 0) {
|
if ($LASTEXITCODE -eq 0) {
|
||||||
Write-Host "Upload successful: ${filename}"
|
Write-Host "Upload successful: ${filename}"
|
||||||
|
|||||||
11
src-tauri/nsis-hooks.nsh
Normal file
11
src-tauri/nsis-hooks.nsh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
; NSIS uninstall hook for Voice to Notes
|
||||||
|
; Removes the sidecar data directory (extracted sidecar binaries + logs)
|
||||||
|
; but preserves user data in $PROFILE\.voicetonotes (database, settings, models)
|
||||||
|
|
||||||
|
!macro NSIS_HOOK_POSTUNINSTALL
|
||||||
|
; Remove the Tauri app_local_data_dir which contains:
|
||||||
|
; - Extracted sidecar directories (voice-to-notes-sidecar/)
|
||||||
|
; - sidecar.log
|
||||||
|
; Path: %LOCALAPPDATA%\com.voicetonotes.app
|
||||||
|
RMDir /r "$LOCALAPPDATA\com.voicetonotes.app"
|
||||||
|
!macroend
|
||||||
@@ -68,15 +68,15 @@ impl SidecarManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Versioned extraction directory prevents stale sidecar after app updates
|
// Versioned extraction directory prevents stale sidecar after app updates
|
||||||
let extract_dir = DATA_DIR
|
let data_dir = DATA_DIR.get().ok_or("App data directory not initialized")?;
|
||||||
.get()
|
let current_version = env!("CARGO_PKG_VERSION");
|
||||||
.ok_or("App data directory not initialized")?
|
let extract_dir = data_dir.join(format!("sidecar-{}", current_version));
|
||||||
.join(format!("sidecar-{}", env!("CARGO_PKG_VERSION")));
|
|
||||||
|
|
||||||
let binary_path = extract_dir.join(binary_name);
|
let binary_path = extract_dir.join(binary_name);
|
||||||
|
|
||||||
// Already extracted — use it directly
|
// Already extracted — use it directly
|
||||||
if binary_path.exists() {
|
if binary_path.exists() {
|
||||||
|
Self::cleanup_old_sidecars(data_dir, current_version);
|
||||||
return Ok(binary_path);
|
return Ok(binary_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +102,7 @@ impl SidecarManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Self::cleanup_old_sidecars(data_dir, current_version);
|
||||||
Ok(binary_path)
|
Ok(binary_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,6 +183,44 @@ impl SidecarManager {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Remove old sidecar-* directories that don't match the current version.
|
||||||
|
/// Called after the current version's sidecar is confirmed ready.
|
||||||
|
fn cleanup_old_sidecars(data_dir: &Path, current_version: &str) {
|
||||||
|
let current_dir_name = format!("sidecar-{}", current_version);
|
||||||
|
|
||||||
|
let entries = match std::fs::read_dir(data_dir) {
|
||||||
|
Ok(entries) => entries,
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("[sidecar-rs] Cannot read data dir for cleanup: {e}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for entry in entries.flatten() {
|
||||||
|
let name = entry.file_name();
|
||||||
|
let name_str = name.to_string_lossy();
|
||||||
|
|
||||||
|
if !name_str.starts_with("sidecar-") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if *name_str == current_dir_name {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if entry.path().is_dir() {
|
||||||
|
eprintln!(
|
||||||
|
"[sidecar-rs] Removing old sidecar: {}",
|
||||||
|
entry.path().display()
|
||||||
|
);
|
||||||
|
if let Err(e) = std::fs::remove_dir_all(entry.path()) {
|
||||||
|
eprintln!(
|
||||||
|
"[sidecar-rs] Failed to remove {}: {e}",
|
||||||
|
entry.path().display()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Find a working Python command for the current platform.
|
/// Find a working Python command for the current platform.
|
||||||
fn find_python_command() -> &'static str {
|
fn find_python_command() -> &'static str {
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"windows": {
|
"windows": {
|
||||||
|
"nsis": {
|
||||||
|
"installerHooks": "nsis-hooks.nsh"
|
||||||
|
},
|
||||||
"wix": {
|
"wix": {
|
||||||
"language": "en-US"
|
"language": "en-US"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user