-
Notifications
You must be signed in to change notification settings - Fork 86
Fix crash when deleting a site #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
453f87e
Keep a list of deleted servers/sites
fluiddot 8a5a08b
Use site ID instead of project path when executing wp-cli commands
fluiddot c5a47dd
Move wp-cli command execution to site server class
fluiddot ad4b3f7
Cancel ongoing messages from wp-cli process
fluiddot 6a5a254
Fix message id calculation in child processes
fluiddot 586f087
Update error message when waiting for a response more than once in wp…
fluiddot 3b85c67
Apply suggestions from code review
fluiddot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ import nodePath from 'path'; | |
| import * as Sentry from '@sentry/electron/main'; | ||
| import archiver from 'archiver'; | ||
| import { copySync } from 'fs-extra'; | ||
| import { parse } from 'shell-quote'; | ||
| import { SQLITE_FILENAME, DEFAULT_PHP_VERSION } from '../vendor/wp-now/src/constants'; | ||
| import { downloadSqliteIntegrationPlugin } from '../vendor/wp-now/src/download'; | ||
| import { LIMIT_ARCHIVE_SIZE } from './constants'; | ||
|
|
@@ -34,7 +33,6 @@ import { | |
| removeLegacySqliteIntegrationPlugin, | ||
| } from './lib/sqlite-versions'; | ||
| import * as windowsHelpers from './lib/windows-helpers'; | ||
| import WpCliProcess from './lib/wp-cli-process'; | ||
| import { writeLogToFile, type LogLevel } from './logging'; | ||
| import { popupMenu } from './menu'; | ||
| import { SiteServer, createSiteWorkingDirectory } from './site-server'; | ||
|
|
@@ -45,6 +43,7 @@ import { | |
| getSiteThumbnailPath, | ||
| } from './storage/paths'; | ||
| import { loadUserData, saveUserData } from './storage/user-data'; | ||
| import type { WpCliResult } from './lib/wp-cli-process'; | ||
|
|
||
| const TEMP_DIR = nodePath.join( app.getPath( 'temp' ), 'com.wordpress.studio' ) + nodePath.sep; | ||
| if ( ! fs.existsSync( TEMP_DIR ) ) { | ||
|
|
@@ -571,20 +570,16 @@ export async function saveOnboarding( | |
|
|
||
| export async function executeWPCLiInline( | ||
| _event: IpcMainInvokeEvent, | ||
| { projectPath, args }: { projectPath: string; args: string } | ||
| ) { | ||
| const wpCliArgs = parse( args ); | ||
|
|
||
| // The parsing of arguments can include shell operators like `>` or `||` that the app don't support. | ||
| const isValidCommand = wpCliArgs.every( | ||
| ( arg: unknown ) => typeof arg === 'string' || arg instanceof String | ||
| ); | ||
| if ( ! isValidCommand ) { | ||
| throw Error( `Can't execute wp-cli command with arguments: ${ args }` ); | ||
| { siteId, args }: { siteId: string; args: string } | ||
| ): Promise< WpCliResult > { | ||
| if ( SiteServer.isDeleted( siteId ) ) { | ||
| return { stdout: '', stderr: `Cannot execute command on deleted site ${ siteId }` }; | ||
| } | ||
|
|
||
| const process = new WpCliProcess(); | ||
| return await process.execute( projectPath, wpCliArgs as string[] ); | ||
| const server = SiteServer.get( siteId ); | ||
| if ( ! server ) { | ||
| throw new Error( 'Site not found.' ); | ||
| } | ||
| return server.executeWpCliCommand( args ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this way of executing wp-cli commands |
||
| } | ||
|
|
||
| export async function getThumbnailData( _event: IpcMainInvokeEvent, id: string ) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,7 @@ export default class SiteServerProcess { | |
| throw Error( 'Server process is not running' ); | ||
| } | ||
|
|
||
| const messageId = +this.lastMessageId; | ||
| const messageId = this.lastMessageId++; | ||
| process.postMessage( { message, messageId, data } ); | ||
|
Comment on lines
85
to
86
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. |
||
| return messageId; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.