mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
fix: assorted fixes across container-runtime, core, and sdk
- Fix parseInt callback in container-runtime to avoid extra map arguments - Use proper error propagation in list_service_interfaces instead of unwrap_or_default - Handle non-plain objects by reference in deepEqual
This commit is contained in:
@@ -494,7 +494,7 @@ export class SystemForEmbassy implements System {
|
||||
const host = new MultiHost({ effects, id })
|
||||
const internalPorts = new Set(
|
||||
Object.values(interfaceValue["tor-config"]?.["port-mapping"] ?? {})
|
||||
.map(Number.parseInt)
|
||||
.map((v) => parseInt(v))
|
||||
.concat(
|
||||
...Object.values(interfaceValue["lan-config"] ?? {}).map(
|
||||
(c) => c.internal,
|
||||
|
||||
@@ -134,8 +134,7 @@ pub async fn list_service_interfaces(
|
||||
.expect("valid json pointer");
|
||||
let mut watch = context.seed.ctx.db.watch(ptr).await;
|
||||
|
||||
let res = imbl_value::from_value(watch.peek_and_mark_seen()?)
|
||||
.unwrap_or_default();
|
||||
let res = from_value(watch.peek_and_mark_seen()?)?;
|
||||
|
||||
if let Some(callback) = callback {
|
||||
let callback = callback.register(&context.seed.persistent_container);
|
||||
@@ -174,9 +173,7 @@ pub async fn clear_service_interfaces(
|
||||
.as_idx_mut(&package_id)
|
||||
.or_not_found(&package_id)?
|
||||
.as_service_interfaces_mut()
|
||||
.mutate(|s| {
|
||||
Ok(s.retain(|id, _| except.contains(id)))
|
||||
})
|
||||
.mutate(|s| Ok(s.retain(|id, _| except.contains(id))))
|
||||
})
|
||||
.await
|
||||
.result?;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
/**
|
||||
* Performs a deep structural equality check across all provided arguments.
|
||||
* Returns true only if every argument is deeply equal to every other argument.
|
||||
* Handles primitives, arrays, and plain objects recursively.
|
||||
* Handles primitives, arrays, and plain objects (JSON-like) recursively.
|
||||
*
|
||||
* Non-plain objects (Set, Map, Date, etc.) are compared by reference only,
|
||||
* since Object.keys() does not enumerate their contents.
|
||||
*
|
||||
* @param args - Two or more values to compare for deep equality
|
||||
* @returns True if all arguments are deeply equal
|
||||
@@ -23,6 +26,18 @@ export function deepEqual(...args: unknown[]) {
|
||||
}
|
||||
if (objects.length !== args.length) return false
|
||||
if (objects.some(Array.isArray) && !objects.every(Array.isArray)) return false
|
||||
if (
|
||||
objects.some(
|
||||
(x) => !Array.isArray(x) && Object.getPrototypeOf(x) !== Object.prototype,
|
||||
)
|
||||
) {
|
||||
return (
|
||||
objects.reduce<object | null>(
|
||||
(a, b) => (a === b ? a : null),
|
||||
objects[0],
|
||||
) !== null
|
||||
)
|
||||
}
|
||||
const allKeys = new Set(objects.flatMap((x) => Object.keys(x)))
|
||||
for (const key of allKeys) {
|
||||
for (const x of objects) {
|
||||
|
||||
Reference in New Issue
Block a user