fix(app): the worker runs the Python sources shipped with this app, not a folder another install stored
The first-run setup writes voiceWorker.cwd; when it ran from another install, an updated app kept starting that install's older sources (found on the game PC: 0.1.1 ran without the screenView tool). Shipped sources next to the executable now always win. Version 0.1.2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2
app/Cargo.lock
generated
2
app/Cargo.lock
generated
@@ -1484,7 +1484,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
||||
|
||||
[[package]]
|
||||
name = "jarvis-app"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "jarvis-app"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
rust-version = "1.85"
|
||||
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"
|
||||
|
||||
4
app/shell/Cargo.lock
generated
4
app/shell/Cargo.lock
generated
@@ -2380,7 +2380,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
||||
|
||||
[[package]]
|
||||
name = "jarvis-app"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"base64 0.22.1",
|
||||
@@ -2408,7 +2408,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "jarvis-shell"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"jarvis-app",
|
||||
"serde_json",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "jarvis-shell"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
rust-version = "1.85"
|
||||
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
|
||||
|
||||
@@ -762,9 +762,11 @@ both to a release with that tag. The repository's other releases (v1's `v1.x`) a
|
||||
quits anyway. Quitting another way (the system shutting down) runs the same shutdown.
|
||||
- `app/shell/package.sh <folder>` builds it on Linux (`x86_64-pc-windows-gnu`, mingw-w64) and lays
|
||||
out `Jarvis/`: `jarvis.exe`, `WebView2Loader.dll`, `python-src/` (the `voice_worker` and
|
||||
`jarvis` packages, no caches or specs) and `display-driver/` (the virtual monitor's driver). The worker's default sources are `python-src` next to the
|
||||
executable when it is there, else the repository's `src/`; the install reads its requirement
|
||||
files from the same place. The folder also runs as it is.
|
||||
`jarvis` packages, no caches or specs) and `display-driver/` (the virtual monitor's driver). The worker's sources are `python-src` next to the
|
||||
executable when it is there, also over a `voiceWorker.cwd` the settings keep (another install's
|
||||
first-run setup may have written its own folder there, and an update must never run those older
|
||||
sources); without shipped sources `voiceWorker.cwd`, else the repository's `src/`. The install
|
||||
reads its requirement files from the same place. The folder also runs as it is.
|
||||
|
||||
## Installer (`app/shell/installer.nsi`, `app/shell/installer.sh`)
|
||||
|
||||
|
||||
@@ -288,6 +288,14 @@ pub fn worker_cwd_for(exe: Option<&Path>) -> PathBuf {
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("src")
|
||||
}
|
||||
|
||||
/// The worker's Python sources: the ones shipped next to the app's executable always win, so an
|
||||
/// update or a second install never runs the older sources a `voiceWorker.cwd` written by another
|
||||
/// install points at; without shipped sources the stored folder, else the default.
|
||||
pub fn worker_cwd(stored: Option<PathBuf>, exe: Option<&Path>) -> PathBuf {
|
||||
let shipped = exe.and_then(Path::parent).map(|d| d.join("python-src")).filter(|p| p.join("voice_worker").is_dir());
|
||||
shipped.or(stored).unwrap_or_else(|| worker_cwd_for(exe))
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
/// The voice worker's arguments: `voiceWorker.args`, plus the voice speed when it speaks
|
||||
/// (`--melo-python`) and the arguments do not set one themselves.
|
||||
@@ -575,11 +583,11 @@ pub fn parse_settings(raw: &Value) -> Result<Settings, SettingsError> {
|
||||
chat_channels,
|
||||
voice_worker: WorkerSettings {
|
||||
python: get_str(worker, "python", "voiceWorker", &d.voice_worker.python)?,
|
||||
cwd: match worker.and_then(|m| m.get("cwd")) {
|
||||
None => d.voice_worker.cwd.clone(),
|
||||
Some(Value::String(s)) => PathBuf::from(s),
|
||||
cwd: worker_cwd(match worker.and_then(|m| m.get("cwd")) {
|
||||
None => None,
|
||||
Some(Value::String(s)) => Some(PathBuf::from(s)),
|
||||
Some(_) => return err("voiceWorker.cwd must be a string"),
|
||||
},
|
||||
}, std::env::current_exe().ok().as_deref()),
|
||||
args: get_str_list(worker, "args", "voiceWorker", &d.voice_worker.args)?,
|
||||
},
|
||||
call,
|
||||
@@ -855,6 +863,19 @@ mod tests {
|
||||
assert_eq!(worker_cwd_for(None), Path::new(env!("CARGO_MANIFEST_DIR")).join("..").join("src"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_worker_folder_stored_by_another_install_never_beats_the_sources_shipped_with_this_app() {
|
||||
// The first-run setup of one install wrote its folder; this app (installed elsewhere, or
|
||||
// updated) must still run its own sources, never the other install's older ones.
|
||||
let dir = crate::datadir::temp_dir("pysrc-stored");
|
||||
let exe = dir.join("jarvis.exe");
|
||||
let other = PathBuf::from("C:/old-install/python-src");
|
||||
assert_eq!(worker_cwd(Some(other.clone()), Some(&exe)), other, "nothing shipped: the stored folder");
|
||||
std::fs::create_dir_all(dir.join("python-src").join("voice_worker")).unwrap();
|
||||
assert_eq!(worker_cwd(Some(other), Some(&exe)), dir.join("python-src"));
|
||||
assert_eq!(worker_cwd(None, Some(&exe)), dir.join("python-src"));
|
||||
}
|
||||
|
||||
const ID: &str = "123456789012345678";
|
||||
const IDN: u64 = 123456789012345678;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user