mirror of
https://github.com/morluto/rea.git
synced 2026-12-02 11:33:10 +00:00
* fix(desktop): preserve exact dpkg ownership from partial queries * test(desktop): cover dpkg executable ownership transcripts * test(desktop): keep executable ownership regression outside describe
29 lines
948 B
TypeScript
29 lines
948 B
TypeScript
import { parseDpkgOwners } from "../domain/desktop/linuxPackages.js";
|
|
import type { QueryRunner } from "./HostQuery.js";
|
|
|
|
/** dpkg may return owner rows and exit 1 when only some requested paths match. */
|
|
export const queryDpkgOwnership = async (
|
|
runQuery: QueryRunner,
|
|
paths: readonly string[],
|
|
signal: AbortSignal | undefined,
|
|
): Promise<
|
|
| {
|
|
readonly kind: "read";
|
|
readonly owners: ReadonlyMap<string, readonly string[]>;
|
|
readonly complete: boolean;
|
|
}
|
|
| { readonly kind: "missing" | "failed" | "unavailable" }
|
|
> => {
|
|
const outcome = await runQuery("dpkg-query", ["-S", ...paths], signal, {
|
|
preserveStdoutBytes: true,
|
|
locale: "C.UTF-8",
|
|
});
|
|
if (typeof outcome === "string") return { kind: outcome };
|
|
if (outcome.exitCode !== 0 && outcome.exitCode !== 1)
|
|
return { kind: "unavailable" };
|
|
return {
|
|
kind: "read",
|
|
...parseDpkgOwners(outcome.stdoutBuffer ?? outcome.stdout, paths),
|
|
};
|
|
};
|