diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2014-04-15 20:07:07 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2014-04-15 20:07:07 +0200 |
commit | 8322a9e5c225b9ed924225b037804e93b06bbc1f (patch) | |
tree | 742c5882c1e6e04746fa01b7bd8a32e373c2e873 /lib | |
parent | ffab31e3ee491b89f2263ee60497526fab5f61f5 (diff) | |
parent | 02726acbc8bfd436dff97eaff575eb2572ecd48b (diff) | |
download | nextcloud-server-8322a9e5c225b9ed924225b037804e93b06bbc1f.tar.gz nextcloud-server-8322a9e5c225b9ed924225b037804e93b06bbc1f.zip |
Merge pull request #8210 from owncloud/enhance-assets-management-master
adding checks and log messages regarding the assets folder
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/templatelayout.php | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index af17adb11c6..0c0c8d9c8d7 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -66,7 +66,7 @@ class OC_TemplateLayout extends OC_Template { } $versionParameter = '?v=' . md5(implode(OC_Util::getVersion())); - $useAssetPipeline = OC_Config::getValue('asset-pipeline.enabled', false); + $useAssetPipeline = $this->isAssetPipelineEnabled(); if ($useAssetPipeline) { $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); @@ -179,4 +179,33 @@ class OC_TemplateLayout extends OC_Template { sort($files); return hash('md5', implode('', $files)); } + + /** + * @return bool + */ + private function isAssetPipelineEnabled() { + // asset management enabled? + $useAssetPipeline = OC_Config::getValue('asset-pipeline.enabled', false); + if (!$useAssetPipeline) { + return false; + } + + // assets folder exists? + $assetDir = \OC::$SERVERROOT . '/assets'; + if (!is_dir($assetDir)) { + if (!mkdir($assetDir)) { + \OCP\Util::writeLog('assets', + "Folder <$assetDir> does not exist and/or could not be generated.", \OCP\Util::ERROR); + return false; + } + } + + // assets folder can be accessed? + if (!touch($assetDir."/.oc")) { + \OCP\Util::writeLog('assets', + "Folder <$assetDir> could not be accessed.", \OCP\Util::ERROR); + return false; + } + return $useAssetPipeline; + } } |