fix(desktop): prevent shared database ownership #6098
Closedmatheustimbo(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/6098/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -0,0 +77,21 @@77+ }).pipe(Effect.orElseSucceed(() => false));78+79+export const ensureDesktopBackendDatabaseAvailable = Effect.fn(80+ "desktop.backendDatabaseOwner.ensureAvailable",81+)(function* (input: {82+ readonly stateDir: string;83+ readonly joinPath: (...parts: ReadonlyArray<string>) => string;84+ readonly isProcessAlive?: (pid: number) => boolean;85+}) {86+ const statePath = input.joinPath(input.stateDir, SERVER_RUNTIME_STATE_FILE_NAME);87+ const runtimeOwner = yield* readRuntimeOwner(statePath);88+ if (Option.isNone(runtimeOwner)) {89+ return;90+ }91+92+ const owner = runtimeOwner.value;93+ if (!(input.isProcessAlive ?? defaultIsProcessAlive)(owner.pid)) {94+ return;95+ }96+97+ if (!(yield* probeT3Server(owner.origin))) {@@ -0,0 +73,21 @@73+ Effect.flatMap(HttpClientResponse.schemaBodyJson(ExecutionEnvironmentDescriptor)),74+ Effect.timeout(SERVER_PROBE_TIMEOUT),75+ );76+ return true;77+ }).pipe(Effect.orElseSucceed(() => false));78+79+export const ensureDesktopBackendDatabaseAvailable = Effect.fn(80+ "desktop.backendDatabaseOwner.ensureAvailable",81+)(function* (input: {82+ readonly stateDir: string;83+ readonly joinPath: (...parts: ReadonlyArray<string>) => string;84+ readonly isProcessAlive?: (pid: number) => boolean;85+}) {86+ const statePath = input.joinPath(input.stateDir, SERVER_RUNTIME_STATE_FILE_NAME);87+ const runtimeOwner = yield* readRuntimeOwner(statePath);88+ if (Option.isNone(runtimeOwner)) {89+ return;90+ }91+92+ const owner = runtimeOwner.value;93+ if (!(input.isProcessAlive ?? defaultIsProcessAlive)(owner.pid)) {
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
531512e1-abdd-4e27-8f76-db5b0fd9e376You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share