updater/index.php
/**
	 * Extracts the download
	 *
	 * @throws \Exception
	 */
Extracts the download
@throws \Exception
Extracts the download @throws \ Exception
public function extractDownload() {
		$this->silentLog('[info] extractDownload()');
		$downloadedFilePath = $this->getDownloadedFilePath();
		$zip = new \ZipArchive;
		$zipState = $zip->open($downloadedFilePath);
		if ($zipState === true) {
			$zip->extractTo(dirname($downloadedFilePath));
			$zip->close();
			$state = unlink($downloadedFilePath);
			if($state === false) {
				throw new \Exception('Cant unlink '. $downloadedFilePath);
			}
		} else {
			throw new \Exception('Cant handle ZIP file. Error code is: '.$zipState);
		}
		$downloadedVersion = $this->getVersionByVersionFile(dirname($downloadedFilePath) . '/nextcloud/version.php');
		$currentVersion = $this->getVersionByVersionFile($this->baseDir . '/../version.php');
		if(version_compare($downloadedVersion, $currentVersion, '<')) {
			throw new \Exception('Downloaded version is lower than installed version');
		}
		$this->silentLog('[info] end of extractDownload()');
	}
public function extractDownload ( ) { $ this -> silentLog ( '[info] extractDownload()' ) ; $ downloadedFilePath = $ this -> getDownloadedFilePath ( ) ; $ zip = new \ ZipArchive ; $ zipState = $ zip -> open ( $ downloadedFilePath ) ; if ( $ zipState === true ) { $ zip -> extractTo ( dirname ( $ downloadedFilePath ) ) ; $ zip -> close ( ) ; $ state = unlink ( $ downloadedFilePath ) ; if ( $ state === false ) { throw new \ Exception ( 'Cant unlink ' . $ downloadedFilePath ) ; } } else { throw new \ Exception ( 'Cant handle ZIP file. Error code is: ' . $ zipState ) ; } $ downloadedVersion = $ this -> getVersionByVersionFile ( dirname ( $ downloadedFilePath ) . '/nextcloud/version.php' ) ; $ currentVersion = $ this -> getVersionByVersionFile ( $ this -> baseDir . '/../version.php' ) ; if ( version_compare ( $ downloadedVersion , $ currentVersion , '<' ) ) { throw new \ Exception ( 'Downloaded version is lower than installed version' ) ; } $ this -> silentLog ( '[info] end of extractDownload()' ) ; }
Extracts the download
 @throws \Exception
Extracts the download @throws \ Exception
// Ensure that the downloaded version is not lower