示例#1
0
 /**
  * upgrades all apps within a major ownCloud upgrade. Also loads "priority"
  * (types authentication, filesystem, logging, in that order) afterwards.
  *
  * @throws NeedsUpdateException
  */
 protected function doAppUpgrade()
 {
     $apps = \OC_App::getEnabledApps();
     $priorityTypes = array('authentication', 'filesystem', 'logging');
     $pseudoOtherType = 'other';
     $stacks = array($pseudoOtherType => array());
     foreach ($apps as $appId) {
         $priorityType = false;
         foreach ($priorityTypes as $type) {
             if (!isset($stacks[$type])) {
                 $stacks[$type] = array();
             }
             if (\OC_App::isType($appId, $type)) {
                 $stacks[$type][] = $appId;
                 $priorityType = true;
                 break;
             }
         }
         if (!$priorityType) {
             $stacks[$pseudoOtherType][] = $appId;
         }
     }
     foreach ($stacks as $type => $stack) {
         foreach ($stack as $appId) {
             if (\OC_App::shouldUpgrade($appId)) {
                 $this->emit('\\OC\\Updater', 'appUpgradeStarted', [$appId, \OC_App::getAppVersion($appId)]);
                 \OC_App::updateApp($appId);
                 $this->emit('\\OC\\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]);
             }
             if ($type !== $pseudoOtherType) {
                 // load authentication, filesystem and logging apps after
                 // upgrading them. Other apps my need to rely on modifying
                 // user and/or filesystem aspects.
                 \OC_App::loadApp($appId, false);
             }
         }
     }
 }
示例#2
0
 /**
  * @brief Update an application
  * @param array $info
  * @param bool $isShipped
  *
  * This function could work like described below, but currently it disables and then
  * enables the app again. This does result in an updated app.
  *
  *
  * This function installs an app. All information needed are passed in the
  * associative array $info.
  * The following keys are required:
  *   - source: string, can be "path" or "http"
  *
  * One of the following keys is required:
  *   - path: path to the file containing the app
  *   - href: link to the downloadable file containing the app
  *
  * The following keys are optional:
  *   - pretend: boolean, if set true the system won't do anything
  *   - noupgrade: boolean, if true appinfo/upgrade.php won't be loaded
  *
  * This function works as follows
  *   -# fetching the file
  *   -# removing the old files
  *   -# unzipping new file
  *   -# including appinfo/upgrade.php
  *   -# setting the installed version
  *
  * upgrade.php can determine the current installed version of the app using
  * "OC_Appconfig::getValue($appid, 'installed_version')"
  */
 public static function updateApp($info = array(), $isShipped = false)
 {
     list($extractDir, $path) = self::downloadApp($info);
     $info = self::checkAppsIntegrity($info, $extractDir, $path, $isShipped);
     $currentDir = OC_App::getAppPath($info['id']);
     $basedir = OC_App::getInstallPath();
     $basedir .= '/';
     $basedir .= $info['id'];
     if ($currentDir !== false && is_writable($currentDir)) {
         $basedir = $currentDir;
     }
     if (is_dir($basedir)) {
         OC_Helper::rmdirr($basedir);
     }
     $appInExtractDir = $extractDir;
     if (substr($extractDir, -1) !== '/') {
         $appInExtractDir .= '/';
     }
     $appInExtractDir .= $info['id'];
     OC_Helper::copyr($appInExtractDir, $basedir);
     OC_Helper::rmdirr($extractDir);
     return OC_App::updateApp($info['id']);
 }
示例#3
0
 protected function doAppUpgrade()
 {
     $apps = \OC_App::getEnabledApps();
     foreach ($apps as $appId) {
         if (\OC_App::shouldUpgrade($appId)) {
             \OC_App::updateApp($appId);
             $this->emit('\\OC\\Updater', 'appUpgrade', array($appId, \OC_App::getAppVersion($appId)));
         }
     }
 }
示例#4
0
文件: app.php 项目: hjimmy/owncloud
 /**
  * check if the app needs updating and update when needed
  */
 public static function checkUpgrade($app)
 {
     if (in_array($app, self::$checkedApps)) {
         return;
     }
     self::$checkedApps[] = $app;
     $versions = self::getAppVersions();
     $currentVersion = OC_App::getAppVersion($app);
     if ($currentVersion) {
         $installedVersion = $versions[$app];
         if (version_compare($currentVersion, $installedVersion, '>')) {
             $info = self::getAppInfo($app);
             OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
             try {
                 OC_App::updateApp($app);
                 OC_Hook::emit('update', 'success', 'Updated ' . $info['name'] . ' app');
             } catch (Exception $e) {
                 OC_Hook::emit('update', 'failure', 'Failed to update ' . $info['name'] . ' app: ' . $e->getMessage());
                 $l = OC_L10N::get('lib');
                 throw new RuntimeException($l->t('Failed to upgrade "%s".', array($app)), 0, $e);
             }
             OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
         }
     }
 }
示例#5
0
文件: app.php 项目: ryanshoover/core
 /**
  * check if the app need updating and update when needed
  */
 public static function checkUpgrade($app)
 {
     if (in_array($app, self::$checkedApps)) {
         return;
     }
     self::$checkedApps[] = $app;
     $versions = self::getAppVersions();
     $currentVersion = OC_App::getAppVersion($app);
     if ($currentVersion) {
         $installedVersion = $versions[$app];
         if (version_compare($currentVersion, $installedVersion, '>')) {
             OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
             try {
                 OC_App::updateApp($app);
             } catch (Exception $e) {
                 echo 'Failed to upgrade "' . $app . '". Exception="' . $e->getMessage() . '"';
                 die;
             }
             OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
         }
     }
 }
示例#6
0
 /**
  * check if any apps need updating and update those
  */
 public static function updateApps()
 {
     $versions = self::getAppVersions();
     //ensure files app is installed for upgrades
     if (!isset($versions['files'])) {
         $versions['files'] = '0';
     }
     foreach ($versions as $app => $installedVersion) {
         $currentVersion = OC_App::getAppVersion($app);
         if ($currentVersion) {
             if (version_compare($currentVersion, $installedVersion, '>')) {
                 OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
                 OC_App::updateApp($app);
                 OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
             }
         }
     }
     // check if the current enabled apps are compatible with the current ownCloud version. disable them if not.
     // this is important if you upgrade ownCloud and have non ported 3rd party apps installed
     $apps = OC_App::getEnabledApps();
     $version = OC_Util::getVersion();
     foreach ($apps as $app) {
         // check if the app is compatible with this version of ownCloud
         $info = OC_App::getAppInfo($app);
         if (!isset($info['require']) or $version[0] > $info['require']) {
             OC_Log::write('core', 'App "' . $info['name'] . '" can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR);
             OC_App::disable($app);
         }
     }
 }
示例#7
0
文件: app.php 项目: noci2012/owncloud
 /**
  * check if any apps need updating and update those
  */
 public static function updateApps()
 {
     $versions = self::getAppVersions();
     //ensure files app is installed for upgrades
     if (!isset($versions['files'])) {
         $versions['files'] = '0';
     }
     foreach ($versions as $app => $installedVersion) {
         $currentVersion = OC_App::getAppVersion($app);
         if ($currentVersion) {
             if (version_compare($currentVersion, $installedVersion, '>')) {
                 OC_Log::write($app, 'starting app upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG);
                 OC_App::updateApp($app);
                 OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
             }
         }
     }
 }