fix(electron): preserve unowned roots without project folders
This commit is contained in:
@@ -418,13 +418,17 @@ it.each(['ready', 'compatible'] as const)(
|
||||
},
|
||||
);
|
||||
|
||||
it('keeps a selected broken environment selected until explicit setup, then preserves unowned files', async () => {
|
||||
it.each([true, false])(
|
||||
'preserves a selected unowned runtime (project exists: %s)',
|
||||
async (projectExists) => {
|
||||
const { resolve, join } = await import('node:path');
|
||||
const selected = resolve('/selected/VoiceStudio');
|
||||
mocks.runtimeConfig = { root: selected, owned: false };
|
||||
mocks.existingProject = true;
|
||||
mocks.existingProject = projectExists;
|
||||
mocks.ready.mockResolvedValue(true);
|
||||
mocks.dependencies.mockImplementation(async (project?: string) => !project?.includes('selected'));
|
||||
mocks.dependencies.mockImplementation(
|
||||
async (project?: string) => !project?.includes('selected'),
|
||||
);
|
||||
mocks.install.mockRejectedValue(new Error('offline'));
|
||||
vi.stubGlobal(
|
||||
'fetch',
|
||||
@@ -447,4 +451,5 @@ it('keeps a selected broken environment selected until explicit setup, then pres
|
||||
expect(mocks.rm).not.toHaveBeenCalled();
|
||||
expect(mocks.stage).not.toHaveBeenCalled();
|
||||
await supervisor.shutdown();
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
@@ -549,8 +549,7 @@ export class BackendSupervisor extends EventEmitter<{
|
||||
configured &&
|
||||
!configured.owned &&
|
||||
samePath(configured.root, runtimeRoot) &&
|
||||
!samePath(runtimeRoot, defaultRuntimeRoot()) &&
|
||||
existsSync(project)
|
||||
!samePath(runtimeRoot, defaultRuntimeRoot())
|
||||
) {
|
||||
// An explicit setup action may create a new runtime, but must never
|
||||
// take ownership of (or repair in place) another installation's files.
|
||||
|
||||
Reference in New Issue
Block a user