Skip to content

Commit

Permalink
adapter changes of index.php
Browse files Browse the repository at this point in the history
  • Loading branch information
CaCO3 committed Oct 27, 2023
1 parent 99dedce commit f44df1a
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions lib/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public function createBackup(): void {
if (!file_exists($backupFolderLocation . '/' . dirname($fileName))) {
$state = mkdir($backupFolderLocation . '/' . dirname($fileName), 0750, true);
if ($state === false) {
throw new \Exception('Could not create folder: '.$backupFolderLocation.'/'.dirname($fileName));
throw new \Exception('Could not create folder: ' . $backupFolderLocation . '/' . dirname($fileName));
}
}

Expand Down Expand Up @@ -506,7 +506,7 @@ private function getUpdateServerResponse(): array {
/** @var false|string $response */
$response = curl_exec($curl);
if ($response === false) {
throw new \Exception('Could not do request to updater server: '.curl_error($curl));
throw new \Exception('Could not do request to updater server: ' . curl_error($curl));
}
curl_close($curl);

Expand Down Expand Up @@ -699,7 +699,7 @@ private function getVersionByVersionFile(string $versionFile): string {
return implode('.', $OC_Version);
}

throw new \Exception("OC_Version not found in $versionFile");
throw new \Exception('OC_Version not found in ' . $versionFile);
}

/**
Expand All @@ -716,15 +716,15 @@ public function extractDownload(): void {
if ($zipState === true) {
$extraction = $zip->extractTo(dirname($downloadedFilePath));
if ($extraction === false) {
throw new \Exception('Error during unpacking zipfile: '.($zip->getStatusString()));
throw new \Exception('Error during unpacking zipfile: ' . ($zip->getStatusString()));
}
$zip->close();
$state = unlink($downloadedFilePath);
if ($state === false) {
throw new \Exception("Can't unlink ". $downloadedFilePath);
throw new \Exception("Could not unlink ". $downloadedFilePath);
}
} else {
throw new \Exception("Can't handle ZIP file. Error code is: ".print_r($zipState, true));
throw new \Exception("Can't handle ZIP file. Error code is: " . print_r($zipState, true));
}

// Ensure that the downloaded version is not lower
Expand Down Expand Up @@ -766,7 +766,7 @@ public function replaceEntryPoints(): void {
}
$state = file_put_contents($this->baseDir . '/../' . $file, $content);
if ($state === false) {
throw new \Exception('Can\'t replace entry point: '.$file);
throw new \Exception('Can\'t replace entry point: ' . $file);
}
}

Expand Down Expand Up @@ -803,10 +803,14 @@ private function recursiveDelete(string $folder): void {
}

foreach ($files as $file) {
unlink($file);
if (unlink($file) === false){
throw new \Exception('Could not unlink ' . $file);
}
}
foreach ($directories as $dir) {
rmdir($dir);
if (rmdir($dir) === false){
throw new \Exception('Could not rmdir ' . $dir);
}
}

$state = rmdir($folder);
Expand Down Expand Up @@ -912,13 +916,10 @@ public function deleteOldFiles(): void {
if ($fileInfo->isFile() || $fileInfo->isLink()) {
$state = unlink($path);
if ($state === false) {
throw new \Exception('Could not unlink: '.$path);
throw new \Exception('Could not unlink: ' . $path);
}
} elseif ($fileInfo->isDir()) {
$state = rmdir($path);
if ($state === false) {
throw new \Exception('Could not rmdir: '.$path);
}
$this->recursiveDelete($path);
}
}

Expand Down Expand Up @@ -969,10 +970,7 @@ private function moveWithExclusions(string $dataLocation, array $excludedElement
}
}
if ($fileInfo->isDir()) {
$state = rmdir($path);
if ($state === false) {
throw new \Exception('Could not rmdir ' . $path);
}
$this->recursiveDelete($path);
}
}
}
Expand Down Expand Up @@ -1014,14 +1012,11 @@ public function finalize(): void {
$storageLocation = $this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOptionMandatoryString('instanceid') . '/downloads/nextcloud/';
$this->silentLog('[info] storage location: ' . $storageLocation);
$this->moveWithExclusions($storageLocation, []);
$state = rmdir($storageLocation);
if ($state === false) {
throw new \Exception('Could not rmdir $storagelocation');
}
$this->recursiveDelete($storageLocation);

$state = unlink($this->getUpdateDirectoryLocation() . '/updater-'.$this->getConfigOptionMandatoryString('instanceid') . '/.step');
if ($state === false) {
throw new \Exception('Could not rmdir .step');
throw new \Exception('Could not unlink .step');
}

if (function_exists('opcache_reset')) {
Expand All @@ -1041,7 +1036,7 @@ private function writeStep(string $state, int $step): void {
if (!file_exists($updaterDir)) {
$result = mkdir($updaterDir);
if ($result === false) {
throw new \Exception('Could not create $updaterDir');
throw new \Exception('Could not create ' . $updaterDir);
}
}
$result = touch($updaterDir . '/.step');
Expand Down

0 comments on commit f44df1a

Please sign in to comment.