@@ -461,7 +461,7 @@ public function createBackup(): void {
461461 if (!file_exists ($ backupFolderLocation . '/ ' . dirname ($ fileName ))) {
462462 $ state = mkdir ($ backupFolderLocation . '/ ' . dirname ($ fileName ), 0750 , true );
463463 if ($ state === false ) {
464- throw new \Exception ('Could not create folder: ' . $ backupFolderLocation . '/ ' . dirname ($ fileName ));
464+ throw new \Exception ('Could not create folder: ' . $ backupFolderLocation. '/ ' . dirname ($ fileName ));
465465 }
466466 }
467467
@@ -544,7 +544,7 @@ private function getUpdateServerResponse(): array {
544544 /** @var false|string $response */
545545 $ response = curl_exec ($ curl );
546546 if ($ response === false ) {
547- throw new \Exception ('Could not do request to updater server: ' . curl_error ($ curl ));
547+ throw new \Exception ('Could not do request to updater server: ' . curl_error ($ curl ));
548548 }
549549 curl_close ($ curl );
550550
@@ -737,7 +737,7 @@ private function getVersionByVersionFile(string $versionFile): string {
737737 return implode ('. ' , $ OC_Version );
738738 }
739739
740- throw new \Exception (' OC_Version not found in ' . $ versionFile );
740+ throw new \Exception (" OC_Version not found in $ versionFile" );
741741 }
742742
743743 /**
@@ -754,15 +754,15 @@ public function extractDownload(): void {
754754 if ($ zipState === true ) {
755755 $ extraction = $ zip ->extractTo (dirname ($ downloadedFilePath ));
756756 if ($ extraction === false ) {
757- throw new \Exception ('Error during unpacking zipfile: ' . ($ zip ->getStatusString ()));
757+ throw new \Exception ('Error during unpacking zipfile: ' . ($ zip ->getStatusString ()));
758758 }
759759 $ zip ->close ();
760760 $ state = unlink ($ downloadedFilePath );
761761 if ($ state === false ) {
762- throw new \Exception ("Could not unlink " . $ downloadedFilePath );
762+ throw new \Exception ("Can't unlink " . $ downloadedFilePath );
763763 }
764764 } else {
765- throw new \Exception ("Can't handle ZIP file. Error code is: " . print_r ($ zipState , true ));
765+ throw new \Exception ("Can't handle ZIP file. Error code is: " . print_r ($ zipState , true ));
766766 }
767767
768768 // Ensure that the downloaded version is not lower
@@ -804,7 +804,7 @@ public function replaceEntryPoints(): void {
804804 }
805805 $ state = file_put_contents ($ this ->baseDir . '/../ ' . $ file , $ content );
806806 if ($ state === false ) {
807- throw new \Exception ('Can \'t replace entry point: ' . $ file );
807+ throw new \Exception ('Can \'t replace entry point: ' . $ file );
808808 }
809809 }
810810
@@ -841,14 +841,10 @@ private function recursiveDelete(string $folder): void {
841841 }
842842
843843 foreach ($ files as $ file ) {
844- if (unlink ($ file ) === false ) {
845- throw new \Exception ('Could not unlink ' . $ file );
846- }
844+ unlink ($ file );
847845 }
848846 foreach ($ directories as $ dir ) {
849- if (rmdir ($ dir ) === false ) {
850- throw new \Exception ('Could not rmdir ' . $ dir );
851- }
847+ rmdir ($ dir );
852848 }
853849
854850 $ state = rmdir ($ folder );
@@ -937,10 +933,7 @@ public function deleteOldFiles(): void {
937933 * @var string $path
938934 * @var \SplFileInfo $fileInfo
939935 */
940- // Build file list first, so the removals won't mess with it
941- /** @var array<string, \SplFileInfo> */
942- $ fileList = iterator_to_array ($ this ->getRecursiveDirectoryIterator (), true );
943- foreach ($ fileList as $ path => $ fileInfo ) {
936+ foreach ($ this ->getRecursiveDirectoryIterator () as $ path => $ fileInfo ) {
944937 $ currentDir = $ this ->baseDir . '/../ ' ;
945938 $ fileName = explode ($ currentDir , $ path )[1 ];
946939 $ folderStructure = explode ('/ ' , $ fileName , -1 );
@@ -957,7 +950,7 @@ public function deleteOldFiles(): void {
957950 if ($ fileInfo ->isFile () || $ fileInfo ->isLink ()) {
958951 $ state = unlink ($ path );
959952 if ($ state === false ) {
960- throw new \Exception ('Could not unlink: ' . $ path );
953+ throw new \Exception ('Could not unlink: ' . $ path );
961954 }
962955 } elseif ($ fileInfo ->isDir ()) {
963956 $ state = rmdir ($ path );
@@ -980,10 +973,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement
980973 * @var string $path
981974 * @var \SplFileInfo $fileInfo
982975 */
983- // Build file list first, so the renames won't mess with it
984- /** @var array<string, \SplFileInfo> */
985- $ fileList = iterator_to_array ($ this ->getRecursiveDirectoryIterator ($ dataLocation ), true );
986- foreach ($ fileList as $ path => $ fileInfo ) {
976+ foreach ($ this ->getRecursiveDirectoryIterator ($ dataLocation ) as $ path => $ fileInfo ) {
987977 $ fileName = explode ($ dataLocation , $ path )[1 ];
988978 $ folderStructure = explode ('/ ' , $ fileName , -1 );
989979
@@ -1064,12 +1054,12 @@ public function finalize(): void {
10641054 $ this ->moveWithExclusions ($ storageLocation , []);
10651055 $ state = rmdir ($ storageLocation );
10661056 if ($ state === false ) {
1067- throw new \Exception ('Could not rmdir ' . $ storageLocation );
1057+ throw new \Exception ('Could not rmdir $storagelocation ' );
10681058 }
10691059
10701060 $ state = unlink ($ this ->getUpdateDirectoryLocation () . '/updater- ' .$ this ->getConfigOptionMandatoryString ('instanceid ' ) . '/.step ' );
10711061 if ($ state === false ) {
1072- throw new \Exception ('Could not unlink .step ' );
1062+ throw new \Exception ('Could not rmdir .step ' );
10731063 }
10741064
10751065 if (function_exists ('opcache_reset ' )) {
@@ -1089,7 +1079,7 @@ private function writeStep(string $state, int $step): void {
10891079 if (!file_exists ($ updaterDir )) {
10901080 $ result = mkdir ($ updaterDir );
10911081 if ($ result === false ) {
1092- throw new \Exception ('Could not create ' . $ updaterDir );
1082+ throw new \Exception ('Could not create $updaterDir ' );
10931083 }
10941084 }
10951085 $ result = touch ($ updaterDir . '/.step ' );
0 commit comments