Example #1
0
 public function create()
 {
     $checkpointName = $this->getCheckpointName();
     $checkpointPath = $this->locator->getCheckpointDir() . '/' . $checkpointName;
     try {
         if (!$this->fsHelper->isWritable($this->locator->getCheckpointDir())) {
             throw new \Exception($this->locator->getCheckpointDir() . ' is not writable.');
         }
         $this->fsHelper->mkdir($checkpointPath);
         $checkpointCorePath = $checkpointPath . '/' . self::CORE_DIR;
         $this->fsHelper->mkdir($checkpointCorePath);
         $core = $this->locator->getRootDirItems();
         foreach ($core as $coreItem) {
             $cpItemPath = $checkpointCorePath . '/' . basename($coreItem);
             $this->fsHelper->copyr($coreItem, $cpItemPath, true);
         }
         //copy config.php
         $configDirSrc = $this->locator->getOwncloudRootPath() . '/config';
         $configDirDst = $checkpointCorePath . '/config';
         $this->fsHelper->copyr($configDirSrc, $configDirDst, true);
         //copy 3rdparty
         $this->fsHelper->copyr($this->locator->getOwncloudRootPath() . '/' . self::THIRDPARTY_DIR, $checkpointCorePath . '/' . self::THIRDPARTY_DIR, true);
         $checkpointAppPath = $checkpointPath . '/' . self::APP_DIR;
         $this->fsHelper->mkdir($checkpointAppPath);
         $appManager = Application::$container['utils.appmanager'];
         $apps = $appManager->getAllApps();
         foreach ($apps as $appId) {
             $appPath = $appManager->getAppPath($appId);
             if ($appPath) {
                 $this->fsHelper->copyr($appPath, $checkpointAppPath . '/' . $appId, true);
             }
         }
     } catch (\Exception $e) {
         $application = Application::$container['application'];
         $application->getLogger()->error($e->getMessage());
         $this->fsHelper->removeIfExists($checkpointPath);
         throw $e;
     }
     return $checkpointName;
 }