Skip to content

Commit 28f1729

Browse files
committed
Just fix
1 parent 34c9689 commit 28f1729

11 files changed

Lines changed: 181 additions & 156 deletions

File tree

Backend/build.rs

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,15 @@ fn main() {
256256

257257
// Navigate: plugins.updater.endpoints
258258
if let Some(plugins) = json.get_mut("plugins")
259-
&& let Some(updater) = plugins.get_mut("updater") {
260-
let endpoints: Vec<serde_json::Value> = channel
261-
.updater_endpoints
262-
.iter()
263-
.map(|s| serde_json::Value::String((*s).to_string()))
264-
.collect();
265-
updater["endpoints"] = serde_json::Value::Array(endpoints);
266-
}
259+
&& let Some(updater) = plugins.get_mut("updater")
260+
{
261+
let endpoints: Vec<serde_json::Value> = channel
262+
.updater_endpoints
263+
.iter()
264+
.map(|s| serde_json::Value::String((*s).to_string()))
265+
.collect();
266+
updater["endpoints"] = serde_json::Value::Array(endpoints);
267+
}
267268

268269
json["mainBinaryName"] = serde_json::Value::String(channel.main_binary_name.into());
269270
json["productName"] = serde_json::Value::String(channel.product_name.into());
@@ -272,9 +273,10 @@ fn main() {
272273
&& let Some(windows) = app
273274
.get_mut("windows")
274275
.and_then(|value| value.as_array_mut())
275-
&& let Some(main_window) = windows.first_mut() {
276-
main_window["title"] = serde_json::Value::String(channel.window_title.into());
277-
}
276+
&& let Some(main_window) = windows.first_mut()
277+
{
278+
main_window["title"] = serde_json::Value::String(channel.window_title.into());
279+
}
278280

279281
// The app should only ever point at a dev server when running `cargo tauri dev`.
280282
// In all other cases (including `cargo build`, `cargo run`, `cargo tauri build`, Flatpak, CI),
@@ -285,17 +287,19 @@ fn main() {
285287
// We build the frontend ahead of time and ship it as production assets.
286288
if strip_dev_server
287289
&& let Some(build) = json.get_mut("build")
288-
&& let Some(build_obj) = build.as_object_mut() {
289-
build_obj.remove("devUrl");
290-
build_obj.remove("beforeDevCommand");
291-
}
290+
&& let Some(build_obj) = build.as_object_mut()
291+
{
292+
build_obj.remove("devUrl");
293+
build_obj.remove("beforeDevCommand");
294+
}
292295

293296
// Flatpak apps update via Flatpak, not the in-app updater.
294297
if is_flatpak_build() {
295298
if let Some(plugins) = json.get_mut("plugins")
296-
&& let Some(updater) = plugins.get_mut("updater") {
297-
updater["active"] = serde_json::Value::Bool(false);
298-
}
299+
&& let Some(updater) = plugins.get_mut("updater")
300+
{
301+
updater["active"] = serde_json::Value::Bool(false);
302+
}
299303
if let Some(bundle) = json.get_mut("bundle") {
300304
bundle["createUpdaterArtifacts"] = serde_json::Value::Bool(false);
301305
}
@@ -353,10 +357,11 @@ fn main() {
353357
println!("cargo:rerun-if-changed=src");
354358

355359
if let Ok(head) = fs::read_to_string(".git/HEAD")
356-
&& let Some(rest) = head.trim().strip_prefix("ref: ") {
357-
let ref_path = format!(".git/{rest}");
358-
println!("cargo:rerun-if-changed={ref_path}");
359-
}
360+
&& let Some(rest) = head.trim().strip_prefix("ref: ")
361+
{
362+
let ref_path = format!(".git/{rest}");
363+
println!("cargo:rerun-if-changed={ref_path}");
364+
}
360365

361366
let branch = git_branch().unwrap_or_else(|| "unknown".into());
362367
let hash = git_short_hash().unwrap_or_else(|| "nogit".into());

Backend/src/logging.rs

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -258,56 +258,58 @@ pub fn init() {
258258
};
259259

260260
// Check if message contains JSON-like structure that can be extracted and formatted.
261-
if msg.len() > 100 && (ts == log::Level::Debug || ts == log::Level::Trace)
262-
&& let (Some(start), Some(end)) = (msg.find('{'), msg.rfind('}')) {
263-
let json_part = &msg[start..=end];
264-
265-
let regex = regex::Regex::new(r#"String\("([^"]*)"\)"#).ok();
266-
267-
// Strategy 1: strict conversion of common Rust debug wrappers.
268-
let mut attempts: Vec<String> = Vec::with_capacity(2);
269-
let mut cleaned = json_part.replace("Object ", "");
270-
if let Some(re) = &regex {
271-
cleaned = re.replace_all(&cleaned, r#""$1""#).to_string();
272-
}
273-
attempts.push(cleaned);
274-
275-
// Strategy 2: aggressive conversion fallback for odd wrapper nesting.
276-
let aggressive = json_part
277-
.replace("Object ", "")
278-
.replace("String(\"", "\"")
279-
.replace("\")", "\"");
280-
attempts.push(aggressive);
281-
282-
for json_clean in attempts {
283-
if let Ok(value) = serde_json::from_str::<serde_json::Value>(&json_clean)
284-
&& let Ok(pretty) = serde_json::to_string_pretty(&value) {
285-
let label = clean_label(&msg[..start]);
286-
let header =
287-
format!("[{}] [{}] {:5} [{}]: {} ", date, time, ts, source, label);
288-
let lines: Vec<&str> = pretty.lines().collect();
289-
return writeln!(
290-
buf,
291-
"{}{}",
292-
header,
293-
lines.join(&format!("\n{}", " ".repeat(header.len())))
294-
);
295-
}
261+
if msg.len() > 100
262+
&& (ts == log::Level::Debug || ts == log::Level::Trace)
263+
&& let (Some(start), Some(end)) = (msg.find('{'), msg.rfind('}'))
264+
{
265+
let json_part = &msg[start..=end];
266+
267+
let regex = regex::Regex::new(r#"String\("([^"]*)"\)"#).ok();
268+
269+
// Strategy 1: strict conversion of common Rust debug wrappers.
270+
let mut attempts: Vec<String> = Vec::with_capacity(2);
271+
let mut cleaned = json_part.replace("Object ", "");
272+
if let Some(re) = &regex {
273+
cleaned = re.replace_all(&cleaned, r#""$1""#).to_string();
274+
}
275+
attempts.push(cleaned);
276+
277+
// Strategy 2: aggressive conversion fallback for odd wrapper nesting.
278+
let aggressive = json_part
279+
.replace("Object ", "")
280+
.replace("String(\"", "\"")
281+
.replace("\")", "\"");
282+
attempts.push(aggressive);
283+
284+
for json_clean in attempts {
285+
if let Ok(value) = serde_json::from_str::<serde_json::Value>(&json_clean)
286+
&& let Ok(pretty) = serde_json::to_string_pretty(&value)
287+
{
288+
let label = clean_label(&msg[..start]);
289+
let header = format!("[{}] [{}] {:5} [{}]: {} ", date, time, ts, source, label);
290+
let lines: Vec<&str> = pretty.lines().collect();
291+
return writeln!(
292+
buf,
293+
"{}{}",
294+
header,
295+
lines.join(&format!("\n{}", " ".repeat(header.len())))
296+
);
296297
}
297-
298-
// Fallback: non-JSON Rust debug structs (e.g., RemoteRelease { ... })
299-
let label = clean_label(&msg[..start]);
300-
let pretty = format_braced(json_part);
301-
let header = format!("[{}] [{}] {:5} [{}]: {} ", date, time, ts, source, label);
302-
let lines: Vec<&str> = pretty.lines().collect();
303-
return writeln!(
304-
buf,
305-
"{}{}",
306-
header,
307-
lines.join(&format!("\n{}", " ".repeat(header.len())))
308-
);
309298
}
310299

300+
// Fallback: non-JSON Rust debug structs (e.g., RemoteRelease { ... })
301+
let label = clean_label(&msg[..start]);
302+
let pretty = format_braced(json_part);
303+
let header = format!("[{}] [{}] {:5} [{}]: {} ", date, time, ts, source, label);
304+
let lines: Vec<&str> = pretty.lines().collect();
305+
return writeln!(
306+
buf,
307+
"{}{}",
308+
header,
309+
lines.join(&format!("\n{}", " ".repeat(header.len())))
310+
);
311+
}
312+
311313
writeln!(buf, "[{}] [{}] {:5} [{}]: {}", date, time, ts, source, msg)
312314
});
313315

Backend/src/plugin_bundles.rs

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -409,24 +409,26 @@ impl PluginBundleStore {
409409
let plugin_dir = self.root.join(&plugin_id);
410410

411411
if let Some(installed) = self.get_current_installed(&plugin_id)?
412-
&& installed.bundle_sha256 == bundle_sha256 && installed.version == version {
413-
write_plugin_source_metadata(&plugin_dir, source_metadata)?;
414-
if auto_approve {
415-
self.approve_capabilities(&plugin_id, &version, true)?;
416-
}
417-
let approval = self
418-
.get_current_installed(&plugin_id)?
419-
.map(|current| current.approval)
420-
.unwrap_or(installed.approval);
421-
return Ok(InstalledPlugin {
422-
plugin_id,
423-
version,
424-
bundle_sha256,
425-
requested_capabilities,
426-
approval,
427-
install_dir: plugin_dir,
428-
});
412+
&& installed.bundle_sha256 == bundle_sha256
413+
&& installed.version == version
414+
{
415+
write_plugin_source_metadata(&plugin_dir, source_metadata)?;
416+
if auto_approve {
417+
self.approve_capabilities(&plugin_id, &version, true)?;
429418
}
419+
let approval = self
420+
.get_current_installed(&plugin_id)?
421+
.map(|current| current.approval)
422+
.unwrap_or(installed.approval);
423+
return Ok(InstalledPlugin {
424+
plugin_id,
425+
version,
426+
bundle_sha256,
427+
requested_capabilities,
428+
approval,
429+
install_dir: plugin_dir,
430+
});
431+
}
430432

431433
let staging = self
432434
.root
@@ -612,9 +614,10 @@ impl PluginBundleStore {
612614
continue;
613615
}
614616
if let Ok(text) = fs::read_to_string(&index_path)
615-
&& let Ok(index) = serde_json::from_str::<InstalledPluginIndex>(&text) {
616-
out.push(index);
617-
}
617+
&& let Ok(index) = serde_json::from_str::<InstalledPluginIndex>(&text)
618+
{
619+
out.push(index);
620+
}
618621
}
619622
out.sort_by(|a, b| a.plugin_id.cmp(&b.plugin_id));
620623
Ok(out)
@@ -869,9 +872,10 @@ fn read_built_in_plugin_ids() -> HashSet<String> {
869872
};
870873
let id = manifest.id.trim();
871874
if !id.is_empty()
872-
&& let Ok(normalized) = normalize_plugin_id(id) {
873-
out.insert(normalized);
874-
}
875+
&& let Ok(normalized) = normalize_plugin_id(id)
876+
{
877+
out.insert(normalized);
878+
}
875879
}
876880
out
877881
}

Backend/src/plugin_paths.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,22 @@ fn bundled_resource_base_dirs(resource_dir_name: &str) -> Vec<PathBuf> {
152152
let _ = resource_dir_name;
153153

154154
if let Ok(exe) = env::current_exe()
155-
&& let Some(dir) = exe.parent() {
156-
push_unique_path(&mut candidates, dir.join("resources"));
157-
push_unique_path(&mut candidates, dir.to_path_buf());
158-
if let Some(target_dir) = dir.parent() {
159-
push_unique_path(&mut candidates, target_dir.join("openvcs"));
160-
#[cfg(target_os = "macos")]
161-
push_unique_path(&mut candidates, target_dir.join("Resources"));
162-
}
163-
#[cfg(target_os = "linux")]
164-
push_linux_package_resource_bases(&mut candidates, dir, resource_dir_name);
165-
push_unique_path(
166-
&mut candidates,
167-
dir.join("_up_").join("target").join("openvcs"),
168-
);
155+
&& let Some(dir) = exe.parent()
156+
{
157+
push_unique_path(&mut candidates, dir.join("resources"));
158+
push_unique_path(&mut candidates, dir.to_path_buf());
159+
if let Some(target_dir) = dir.parent() {
160+
push_unique_path(&mut candidates, target_dir.join("openvcs"));
161+
#[cfg(target_os = "macos")]
162+
push_unique_path(&mut candidates, target_dir.join("Resources"));
169163
}
164+
#[cfg(target_os = "linux")]
165+
push_linux_package_resource_bases(&mut candidates, dir, resource_dir_name);
166+
push_unique_path(
167+
&mut candidates,
168+
dir.join("_up_").join("target").join("openvcs"),
169+
);
170+
}
170171

171172
if let Some(resource_dir) = RESOURCE_DIR.get() {
172173
push_unique_path(&mut candidates, resource_dir.clone());

Backend/src/plugin_runtime/manager.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,10 @@ impl PluginRuntimeManager {
375375
let running: Vec<String> = self.processes.lock().keys().cloned().collect();
376376
for plugin_id in running {
377377
if !desired_running.contains(&plugin_id)
378-
&& let Err(err) = self.stop_plugin(&plugin_id) {
379-
errors.push(format!("stop {}: {}", plugin_id, err));
380-
}
378+
&& let Err(err) = self.stop_plugin(&plugin_id)
379+
{
380+
errors.push(format!("stop {}: {}", plugin_id, err));
381+
}
381382
}
382383

383384
let after: Vec<String> = self.processes.lock().keys().cloned().collect();
@@ -539,12 +540,13 @@ impl PluginRuntimeManager {
539540

540541
let mut lock = self.processes.lock();
541542
if let Some(existing) = lock.get(&spec.key)
542-
&& existing.workspace_root == spec.spawn.allowed_workspace_root {
543-
let runtime = Arc::clone(&existing.runtime);
544-
drop(lock);
545-
trace!("start_plugin_spec: found concurrent insert, reusing");
546-
return runtime.ensure_running();
547-
}
543+
&& existing.workspace_root == spec.spawn.allowed_workspace_root
544+
{
545+
let runtime = Arc::clone(&existing.runtime);
546+
drop(lock);
547+
trace!("start_plugin_spec: found concurrent insert, reusing");
548+
return runtime.ensure_running();
549+
}
548550

549551
let runtime_to_stop = lock
550552
.get(&spec.key)

Backend/src/plugin_runtime/node_instance.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,10 @@ impl NodePluginRuntimeInstance {
371371
.ok_or_else(|| "node runtime did not initialize".to_string())?;
372372
let result = f(process);
373373
if let Err(err) = &result
374-
&& err.contains("disconnected") {
375-
lock.take();
376-
}
374+
&& err.contains("disconnected")
375+
{
376+
lock.take();
377+
}
377378
result
378379
}
379380

Backend/src/state.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,10 @@ fn load_recents_from_disk() -> Result<Vec<PathBuf>, String> {
268268
}
269269
serde_json::Value::Object(map) => {
270270
if let Some(serde_json::Value::String(s)) = map.get("path")
271-
&& !s.trim().is_empty() {
272-
out.push(PathBuf::from(s));
273-
}
271+
&& !s.trim().is_empty()
272+
{
273+
out.push(PathBuf::from(s));
274+
}
274275
}
275276
_ => {}
276277
}

0 commit comments

Comments
 (0)