コード例 #1
0
ファイル: apps.php プロジェクト: BacLuc/newGryfiPage
	public function update($tmpDir = '') {
		Helper::mkdir($tmpDir, true);
		$this->collect();
		try {
			foreach ($this->appsToUpdate as $appId) {
				if (!@file_exists($this->newBase . '/' . $appId)){
					continue;
				}
				$path = \OC_App::getAppPath($appId);
				if ($path) {
					Helper::move($path, $tmpDir . '/' . $appId);
					
					// ! reverted intentionally
					$this->done [] = array(
						'dst' => $path,
						'src' => $tmpDir . '/' . $appId
					);
					
					Helper::move($this->newBase . '/' . $appId, $path);
				} else { 
					// The app is new and doesn't exist in the current instance
					$pathData = first(\OC::$APPSROOTS);
					Helper::move($this->newBase . '/' . $appId, $pathData['path'] . '/' . $appId);
				}
			}
			$this->finalize();
		} catch (\Exception $e) {
			$this->rollback(true);
			throw $e;
		}
	}
コード例 #2
0
ファイル: application.php プロジェクト: amin-hedayati/updater
 public function __construct(array $urlParams = [])
 {
     parent::__construct('updater', $urlParams);
     $container = $this->getContainer();
     /**
      * Controllers
      */
     $container->registerService('UpdateController', function ($c) {
         return new UpdateController($c->query('AppName'), $c->query('Request'), $c->query('L10N'));
     });
     $container->registerService('BackupController', function ($c) {
         return new BackupController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
     });
     $container->registerService('AdminController', function ($c) {
         return new AdminController($c->query('AppName'), $c->query('Request'), $c->query('Config'), $c->query('L10N'));
     });
     $container->registerService('L10N', function ($c) {
         return $c->query('ServerContainer')->getL10N($c->query('AppName'));
     });
     $container->registerService('Config', function ($c) {
         return new Config($c->query('ServerContainer')->getConfig());
     });
     $container->registerService('Channel', function ($c) {
         return new Channel($c->query('L10N'));
     });
     //Startup
     if (\OC_Util::getEditionString() === '') {
         \OCP\App::registerAdmin('updater', 'admin');
         $appPath = $container->query('Config')->getBackupBase();
         if (!@file_exists($appPath)) {
             Helper::mkdir($appPath);
         }
     }
 }
コード例 #3
0
ファイル: core.php プロジェクト: enoch85/owncloud-testserver
 protected function finalize()
 {
     // overwrite themes content with new files only
     $themes = $this->toAbsolute($this->newBase . '/themes', Helper::scandir($this->newBase . '/themes'));
     foreach ($themes as $name => $location) {
         Helper::removeIfExists($this->oldBase . '/themes/' . $name);
         Helper::move($location, $this->oldBase . '/themes/' . $name);
     }
     parent::finalize();
 }
コード例 #4
0
 public function delete($filename)
 {
     // Prevent directory traversal
     $file = basename($filename);
     if (strlen($file) < 3) {
         exit;
     }
     $filename = $this->config->getBackupBase() . $file;
     Helper::removeIfExists($filename);
 }
コード例 #5
0
 public function backup()
 {
     clearstatcache();
     try {
         // Url to download package e.g. http://download.owncloud.org/releases/owncloud-8.0.2.tar.bz2
         $packageUrl = '';
         //Package version e.g. 8.0.2
         $packageVersion = '';
         $updateData = $this->channel->getFeed();
         if (!empty($updateData['version'])) {
             $packageVersion = $updateData['version'];
         }
         if (!empty($updateData['url'])) {
             $packageUrl = $updateData['url'];
         }
         if (!strlen($packageVersion) || !strlen($packageUrl)) {
             \OC::$server->getLogger()->error('Invalid response from update feed.', ['app' => 'updater']);
             throw new \Exception((string) $this->l10n->t('Version not found'));
         }
         $packageVersionArray = explode('.', $packageVersion);
         Helper::checkVersion($packageVersionArray, $packageVersion);
         //Some cleanup first
         Downloader::cleanUp($packageVersion);
         if (!Downloader::isClean($packageVersion)) {
             $message = $this->l10n->t('Upgrade is not possible. Your web server does not have permission to remove the following directory:');
             $message .= '<br />' . Downloader::getPackageDir($packageVersion);
             $message .= '<br />' . $this->l10n->t('Update permissions on this directory and its content or remove it manually first.');
             throw new \Exception($message);
         }
         Updater::cleanUp();
         if (!Updater::isClean()) {
             $message = $this->l10n->t('Upgrade is not possible. Your web server does not have permission to remove the following directory:');
             $message .= '<br />' . Updater::getTempDir();
             $message .= '<br />' . $this->l10n->t('Update permissions on this directory and its content or remove it manually first.');
             throw new \Exception($message);
         }
         $backupPath = Backup::create($packageVersion);
         $result = ['status' => 'success', 'backup' => $backupPath, 'version' => $packageVersion, 'url' => $packageUrl];
     } catch (PermissionException $e) {
         //Something is not writable|readable
         $result = ['status' => 'error', 'message' => $e->getExtendedMessage()];
     } catch (FsException $e) {
         //Backup failed
         \OC::$server->getLogger()->error($e->getMessage(), ['app' => 'updater']);
         $result = ['status' => 'error', 'message' => $e->getMessage()];
     } catch (\Exception $e) {
         //Something went wrong. We don't know what
         \OC::$server->getLogger()->error($e->getMessage(), ['app' => 'updater']);
         $result = ['status' => 'error', 'message' => $e->getMessage()];
     }
     return $result;
 }