Skip to content

Commit 87e01a2

Browse files
author
Alex Schulte
committed
display an error, if a backup archive file wasn't created
1 parent e5b15b9 commit 87e01a2

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Classes/Command/BackupCommandController.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ public function createCommand(): void
2424
$this->quit();
2525
}
2626

27-
$this->output('Creating backup...');
28-
$this->backupService->createBackup();
29-
$this->outputLine('<success>success</success>');
27+
$this->outputLine('Creating backup...');
28+
29+
if (!$this->backupService->createBackup()) {
30+
$this->outputLine('<error>couldn\'t create backup</error>');
31+
$this->quit();
32+
}
33+
34+
$this->outputLine('<success>backup created</success>');
3035
}
3136

3237
/**

Classes/Service/BackupService.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,23 @@ public function createBackup()
148148
// create archive
149149
$compressor = $this->getCompressor();
150150
$archivePath = $compressor->compress($backupPath, $this->config['tempPath']);
151+
152+
if (!is_file($archivePath)) {
153+
$this->logger->error('couldn\`t create backup archive file: ' . $archivePath);
154+
155+
return false;
156+
}
157+
151158
// upload to file system and delete local one
152159
$this->filesystem->writeStream(basename($archivePath), fopen($archivePath, 'r'));
153160
unlink($archivePath);
154161
Files::removeDirectoryRecursively($backupPath);
162+
155163
// update index
156164
$this->indexService->addBackup($backupName, new \DateTime(), $meta);
157165
$this->logger->info('added backup '.$backupName);
166+
167+
return true;
158168
}
159169

160170
/**

0 commit comments

Comments
 (0)