]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding checks and log messages regarding the assets folder
authorThomas Müller <thomas.mueller@tmit.eu>
Tue, 15 Apr 2014 14:26:12 +0000 (16:26 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 15 Apr 2014 14:26:12 +0000 (16:26 +0200)
lib/private/templatelayout.php

index af17adb11c6864085551c6ecc98b37eae5012d7a..0c0c8d9c8d7b7b985efea52eec889590e001c991 100644 (file)
@@ -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;
+       }
 }