From ffdb94091a763afc0693381f2da17e9b683ad573 Mon Sep 17 00:00:00 2001 From: bcotrim Date: Wed, 8 Apr 2026 11:05:44 +0100 Subject: [PATCH] Fix sync pull getting stuck when site has broken SQLite integration --- apps/studio/src/ipc-handlers.ts | 6 +++++- apps/studio/src/lib/sqlite-versions.ts | 3 +++ .../src/stores/sync/sync-operations-slice.ts | 19 +++++++++++-------- apps/studio/src/tests/ipc-handlers.test.ts | 6 ++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/apps/studio/src/ipc-handlers.ts b/apps/studio/src/ipc-handlers.ts index bfccf6b4f2..1b2a937fee 100644 --- a/apps/studio/src/ipc-handlers.ts +++ b/apps/studio/src/ipc-handlers.ts @@ -70,7 +70,7 @@ import { setSentryWpcomUserIdMain } from 'src/lib/main-sentry-utils'; import * as oauthClient from 'src/lib/oauth'; import { getAiInstructionsPath } from 'src/lib/server-files-paths'; import { shellOpenExternalWrapper } from 'src/lib/shell-open-external-wrapper'; -import { keepSqliteIntegrationUpdated } from 'src/lib/sqlite-versions'; +import { installSqliteIntegration, keepSqliteIntegrationUpdated } from 'src/lib/sqlite-versions'; import * as windowsHelpers from 'src/lib/windows-helpers'; import { setupWordPressFilesOnly } from 'src/lib/wordpress-setup'; import { getLogsFilePath, writeLogToFile, type LogLevel } from 'src/logging'; @@ -363,6 +363,10 @@ export async function importSite( await setupWordPressFilesOnly( site.details.path ); } + if ( ! ( await site.hasSQLitePlugin() ) ) { + await installSqliteIntegration( site.details.path ); + } + const onEvent = ( data: ImportExportEventData ) => { const parentWindow = BrowserWindow.fromWebContents( event.sender ); sendIpcEventToRendererWithWindow( parentWindow, 'on-import', data, id ); diff --git a/apps/studio/src/lib/sqlite-versions.ts b/apps/studio/src/lib/sqlite-versions.ts index b108ac2180..40c30a46f8 100644 --- a/apps/studio/src/lib/sqlite-versions.ts +++ b/apps/studio/src/lib/sqlite-versions.ts @@ -19,3 +19,6 @@ export const getSqliteVersionFromInstallation = ( sqliteMuPluginPath: string ) = export const keepSqliteIntegrationUpdated = ( sitePath: string ) => provider.keepSqliteIntegrationUpdated( sitePath ); + +export const installSqliteIntegration = ( sitePath: string ) => + provider.installSqliteIntegration( sitePath ); diff --git a/apps/studio/src/stores/sync/sync-operations-slice.ts b/apps/studio/src/stores/sync/sync-operations-slice.ts index 2e7dd736ed..9946a27585 100644 --- a/apps/studio/src/stores/sync/sync-operations-slice.ts +++ b/apps/studio/src/stores/sync/sync-operations-slice.ts @@ -844,14 +844,17 @@ const pollPullBackupThunk = createTypedAsyncThunk( ); await getIpcApi().stopServer( selectedSiteId ); - await getIpcApi().importSite( { - id: selectedSiteId, - backupFile: { - path: filePath, - type: 'application/tar+gzip', - }, - } ); - await getIpcApi().startServer( selectedSiteId ); + try { + await getIpcApi().importSite( { + id: selectedSiteId, + backupFile: { + path: filePath, + type: 'application/tar+gzip', + }, + } ); + } finally { + await getIpcApi().startServer( selectedSiteId ); + } await getIpcApi().removeSyncBackup( remoteSiteId ); diff --git a/apps/studio/src/tests/ipc-handlers.test.ts b/apps/studio/src/tests/ipc-handlers.test.ts index 730b1cf7b4..73a861f1bd 100644 --- a/apps/studio/src/tests/ipc-handlers.test.ts +++ b/apps/studio/src/tests/ipc-handlers.test.ts @@ -35,6 +35,10 @@ vi.mock( 'src/lib/wordpress-setup', () => ( { } ) ); vi.mock( 'src/main-window' ); vi.mock( 'src/lib/import-export/import/import-manager' ); +vi.mock( 'src/lib/sqlite-versions', () => ( { + keepSqliteIntegrationUpdated: vi.fn().mockResolvedValue( false ), + installSqliteIntegration: vi.fn().mockResolvedValue( undefined ), +} ) ); vi.mock( import( 'src/lib/bump-stats' ), async ( importOriginal ) => { const actual = await importOriginal(); return { @@ -195,6 +199,7 @@ describe( 'importSite', () => { start: vi.fn(), stop: vi.fn(), updateSiteDetails: vi.fn(), + hasSQLitePlugin: vi.fn().mockResolvedValue( true ), executeWpCliCommand: vi .fn() .mockResolvedValue( { stdout: 'New Site Title', stderr: '', exitCode: 0 } ), @@ -244,6 +249,7 @@ describe( 'importSite', () => { start: vi.fn(), stop: vi.fn(), updateSiteDetails: vi.fn(), + hasSQLitePlugin: vi.fn().mockResolvedValue( true ), executeWpCliCommand: vi .fn() .mockResolvedValue( { stdout: 'New Site Title', stderr: '', exitCode: 0 } ),