protected function writeData() { $configFilePath = current($this->locator->getPathtoConfigFiles()); // Create a php file ... $content = "<?php\n"; $content .= '$CONFIG = '; $content .= var_export($this->cache, true); $content .= ";\n"; touch($configFilePath); $filePointer = fopen($configFilePath, 'r+'); // Prevent others not to read the config chmod($configFilePath, 0640); // File does not exist, this can happen when doing a fresh install if (!is_resource($filePointer)) { $url = \OC_Helper::linkToDocs('admin-dir_permissions'); throw new HintException("Can't write into config directory!", 'This can usually be fixed by ' . '<a href="' . $url . '" target="_blank">giving the webserver write access to the config directory</a>.'); } // Try to acquire a file lock if (!flock($filePointer, LOCK_EX)) { throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $configFilePath)); } // Write the config and release the lock ftruncate($filePointer, 0); fwrite($filePointer, $content); fflush($filePointer); flock($filePointer, LOCK_UN); fclose($filePointer); }
public function run($args) { $occPath = $this->locator->getPathToOccFile(); $cmd = "php {$occPath} {$args}"; $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return $process->getOutput(); }
/** * Produce complete feed URL * @return string */ protected function getFeedUrl() { $currentVersion = $this->configReader->getByPath('system.version'); $version = explode('.', $currentVersion); $version['installed'] = $this->configReader->getByPath('apps.core.installedat'); $version['updated'] = $this->configReader->getByPath('apps.core.lastupdatedat'); $version['updatechannel'] = $this->getUpdateChannel(); $version['edition'] = $this->configReader->getEdition(); $version['build'] = $this->locator->getBuild(); $url = self::DEFAULT_BASE_URL . '?version=' . implode('x', $version); return $url; }
protected function runAsProcess($cmdLine) { $occPath = $this->locator->getPathToOccFile(); $cmd = "php {$occPath} --no-warnings {$cmdLine}"; $process = new Process($cmd); $process->setTimeout(null); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } return $process->getOutput(); }
/** * Produce complete feed URL * @return string */ protected function getFeedUrl() { $currentVersion = $this->configReader->getByPath('system.version'); $version = explode('.', $currentVersion); $version['installed'] = $this->configReader->getByPath('apps.core.installedat'); $version['updated'] = $this->configReader->getByPath('apps.core.lastupdatedat'); $version['updatechannel'] = $this->getUpdateChannel(); $version['edition'] = $this->configReader->getEdition(); $version['build'] = $this->locator->getBuild(); // Read updater server URL from config $updaterServerUrl = $this->configReader->get(['system', 'updater.server.url']); if ((bool) $updaterServerUrl === false) { $updaterServerUrl = self::DEFAULT_BASE_URL; } $url = $updaterServerUrl . '?version=' . implode('x', $version); return $url; }
protected function getCheckpointName() { $versionString = implode('.', $this->locator->getInstalledVersion()); return uniqid($versionString . '-'); }
/** * Get an absolute path to the checkpoint directory by checkpoint Id * @param string $checkpointId id of checkpoint * @return string */ public function getCheckpointPath($checkpointId) { return $this->locator->getCheckpointDir() . '/' . $checkpointId; }