From cb7772d96d5c51b277bf42164f6a1d0cf06d051e Mon Sep 17 00:00:00 2001 From: rvogel Date: Tue, 25 Jun 2024 13:04:38 +0200 Subject: [PATCH] Check if ZIP file gets created properlyi See https://github.com/hallowelt/misc-mediawiki-adm/issues/21 --- src/Commands/WikiBackup.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Commands/WikiBackup.php b/src/Commands/WikiBackup.php index c808ab1..fd4c466 100644 --- a/src/Commands/WikiBackup.php +++ b/src/Commands/WikiBackup.php @@ -141,8 +141,11 @@ protected function execute( Input\InputInterface $input, OutputInterface $output $this->addCustomFilesAndFolders(); $this->dumpDatabase(); - $this->zip->close(); + $success = $this->zip->close(); $this->cleanUp(); + if ( !$success ) { + throw new \Exception( "Could not close ZIP file!" ); + } $this->removeOldBackups(); @@ -205,10 +208,13 @@ protected function initZipFile() { $destFilePath = $this->makeDestFilepath(); $this->output->writeln( "Creating file '$destFilePath' ..." ); $this->zip = new ZipArchive(); - $this->zip->open( + $success = $this->zip->open( $destFilePath, ZipArchive::CREATE|ZipArchive::OVERWRITE ); + if ( !$success ) { + throw new \Exception( "Could not create ZIP file '$destFilePath'!" ); + } } protected function makeDestFilepath() {