Skip to content

Commit 8022d20

Browse files
committed
fix(backup): add file existence checks for all 7z operations
Add missing file existence checks in backup_wp_content_dir() and backup_db() for consistency with other backup functions. This ensures archive integrity is verified after all 7z operations.
1 parent 184358d commit 8022d20

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/helper/Site_Backup_Restore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ private function backup_wp_content_dir( $backup_dir ) {
480480
$result = EE::launch( $backup_command );
481481

482482
// 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
483-
if ( $result->return_code >= 2 ) {
483+
if ( $result->return_code >= 2 || ! $this->fs->exists( $backup_file ) ) {
484484
$this->capture_error(
485485
'Failed to create WordPress content backup archive',
486486
self::ERROR_TYPE_FILESYSTEM,
@@ -499,7 +499,7 @@ private function backup_wp_content_dir( $backup_dir ) {
499499
$this->fs->remove( $meta_file );
500500

501501
// 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
502-
if ( $result->return_code >= 2 ) {
502+
if ( $result->return_code >= 2 || ! $this->fs->exists( $backup_file ) ) {
503503
$this->capture_error(
504504
'Failed to create WordPress content backup archive',
505505
self::ERROR_TYPE_FILESYSTEM,
@@ -642,7 +642,7 @@ private function backup_db( $backup_dir ) {
642642
$result = EE::launch( $backup_command );
643643

644644
// 7z exit codes: 0=success, 1=warning (non-fatal), 2+=fatal error
645-
if ( $result->return_code >= 2 ) {
645+
if ( $result->return_code >= 2 || ! $this->fs->exists( $backup_file ) ) {
646646
$this->capture_error(
647647
'Failed to compress database backup into archive',
648648
self::ERROR_TYPE_FILESYSTEM,

0 commit comments

Comments
 (0)