22namespace Breadlesscode \Backups \Service ;
33
44use Breadlesscode \Backups \Compressor \BackupCompressorInterface ;
5- use Breadlesscode \Backups \BackupStep \StepInterface ;
65use Breadlesscode \Backups \Factory \FilesystemFactory ;
7- use Breadlesscode \Backups \Generators \BackupNameBackupNameGenerator ;
86use Breadlesscode \Backups \Generators \BackupNameGeneratorInterface ;
7+ use Breadlesscode \Backups \Step \StepInterface ;
98use League \Flysystem \FileNotFoundException ;
109use League \Flysystem \Filesystem ;
1110use Neos \Flow \Annotations as Flow ;
@@ -48,7 +47,7 @@ class BackupService
4847 protected $ persistenceManager ;
4948
5049 /**
51- * @var LoggerInterface#
50+ * @var LoggerInterface
5251 */
5352 protected $ logger ;
5453
@@ -126,12 +125,9 @@ public function restoreBackup(string $name)
126125 /**
127126 * @throws Exception
128127 * @throws \League\Flysystem\FileExistsException
129- * @throws \Neos\Flow\Configuration\Exception\InvalidConfigurationTypeException
130- * @throws \Neos\Flow\ObjectManagement\Exception\CannotBuildObjectException
131- * @throws \Neos\Flow\ObjectManagement\Exception\UnknownObjectException
132128 * @throws \Neos\Utility\Exception\FilesException
133129 */
134- public function createBackup ()
130+ public function createBackup (): bool
135131 {
136132 $ backupName = $ this ->generateBackupName ();
137133 $ backupPath = $ this ->getTemporaryBackupPath ($ backupName );
@@ -145,16 +141,27 @@ public function createBackup()
145141 /** @var StepInterface $step */
146142 $ step ->backup ();
147143 }
144+
148145 // create archive
149146 $ compressor = $ this ->getCompressor ();
150147 $ archivePath = $ compressor ->compress ($ backupPath , $ this ->config ['tempPath ' ]);
148+
149+ if (!is_file ($ archivePath )) {
150+ $ this ->logger ->error ('couldn\`t create backup archive file: ' . $ archivePath );
151+
152+ return false ;
153+ }
154+
151155 // upload to file system and delete local one
152156 $ this ->filesystem ->writeStream (basename ($ archivePath ), fopen ($ archivePath , 'r ' ));
153157 unlink ($ archivePath );
154158 Files::removeDirectoryRecursively ($ backupPath );
159+
155160 // update index
156161 $ this ->indexService ->addBackup ($ backupName , new \DateTime (), $ meta );
157162 $ this ->logger ->info ('added backup ' .$ backupName );
163+
164+ return true ;
158165 }
159166
160167 /**
0 commit comments