adding cssmin and jssmin(minify)
adding argument deleteSelf to rmdirr() - if false the directory itself will not be deleted only it's content adding repair step to clean the asset cache after upgrade + coding style adjustments
This commit is contained in:
parent
688a141586
commit
93b0f1a3bf
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
||||||
Subproject commit 5db359cb710c51747d3fb78b605f8b8cdcd1e605
|
Subproject commit 635aaf81d0d97f000c9d4b90fc5a3240d05cf371
|
|
@ -402,9 +402,10 @@ class OC_Helper {
|
||||||
/**
|
/**
|
||||||
* Recursive deletion of folders
|
* Recursive deletion of folders
|
||||||
* @param string $dir path to the folder
|
* @param string $dir path to the folder
|
||||||
|
* @param bool $deleteSelf if set to false only the content of the folder will be deleted
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
static function rmdirr($dir) {
|
static function rmdirr($dir, $deleteSelf = true) {
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$files = new RecursiveIteratorIterator(
|
$files = new RecursiveIteratorIterator(
|
||||||
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
|
new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
|
||||||
|
@ -419,15 +420,19 @@ class OC_Helper {
|
||||||
unlink($fileInfo->getRealPath());
|
unlink($fileInfo->getRealPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rmdir($dir);
|
if ($deleteSelf) {
|
||||||
|
rmdir($dir);
|
||||||
|
}
|
||||||
} elseif (file_exists($dir)) {
|
} elseif (file_exists($dir)) {
|
||||||
unlink($dir);
|
if ($deleteSelf) {
|
||||||
|
unlink($dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (file_exists($dir)) {
|
if (!$deleteSelf) {
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return !file_exists($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,13 @@ namespace OC;
|
||||||
|
|
||||||
use OC\Hooks\BasicEmitter;
|
use OC\Hooks\BasicEmitter;
|
||||||
use OC\Hooks\Emitter;
|
use OC\Hooks\Emitter;
|
||||||
|
use OC\Repair\AssetCache;
|
||||||
|
use OC\Repair\Collation;
|
||||||
|
use OC\Repair\InnoDB;
|
||||||
|
use OC\Repair\RepairConfig;
|
||||||
|
use OC\Repair\RepairLegacyStorages;
|
||||||
|
use OC\Repair\RepairMimeTypes;
|
||||||
|
use OC\Repair\SearchLuceneTables;
|
||||||
|
|
||||||
class Repair extends BasicEmitter {
|
class Repair extends BasicEmitter {
|
||||||
/**
|
/**
|
||||||
|
@ -69,9 +76,10 @@ class Repair extends BasicEmitter {
|
||||||
*/
|
*/
|
||||||
public static function getRepairSteps() {
|
public static function getRepairSteps() {
|
||||||
return array(
|
return array(
|
||||||
new \OC\Repair\RepairMimeTypes(),
|
new RepairMimeTypes(),
|
||||||
new \OC\Repair\RepairLegacyStorages(\OC::$server->getConfig(), \OC_DB::getConnection()),
|
new RepairLegacyStorages(\OC::$server->getConfig(), \OC_DB::getConnection()),
|
||||||
new \OC\Repair\RepairConfig(),
|
new RepairConfig(),
|
||||||
|
new AssetCache()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,14 +91,14 @@ class Repair extends BasicEmitter {
|
||||||
*/
|
*/
|
||||||
public static function getBeforeUpgradeRepairSteps() {
|
public static function getBeforeUpgradeRepairSteps() {
|
||||||
$steps = array(
|
$steps = array(
|
||||||
new \OC\Repair\InnoDB(),
|
new InnoDB(),
|
||||||
new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
|
new Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
|
||||||
new \OC\Repair\SearchLuceneTables()
|
new SearchLuceneTables()
|
||||||
);
|
);
|
||||||
|
|
||||||
//There is no need to delete all previews on every single update
|
//There is no need to delete all previews on every single update
|
||||||
//only 7.0.0 thru 7.0.2 generated broken previews
|
//only 7.0.0 through 7.0.2 generated broken previews
|
||||||
$currentVersion = \OC_Config::getValue('version');
|
$currentVersion = \OC::$server->getConfig()->getSystemValue('version');
|
||||||
if (version_compare($currentVersion, '7.0.0.0', '>=') &&
|
if (version_compare($currentVersion, '7.0.0.0', '>=') &&
|
||||||
version_compare($currentVersion, '7.0.2.2', '<=')) {
|
version_compare($currentVersion, '7.0.2.2', '<=')) {
|
||||||
$steps[] = new \OC\Repair\Preview();
|
$steps[] = new \OC\Repair\Preview();
|
||||||
|
@ -102,7 +110,7 @@ class Repair extends BasicEmitter {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*
|
*
|
||||||
* Redeclared as public to allow invocation from within the closure above in php 5.3
|
* Re-declared as public to allow invocation from within the closure above in php 5.3
|
||||||
*/
|
*/
|
||||||
public function emit($scope, $method, $arguments = array()) {
|
public function emit($scope, $method, $arguments = array()) {
|
||||||
parent::emit($scope, $method, $arguments);
|
parent::emit($scope, $method, $arguments);
|
||||||
|
|
|
@ -198,8 +198,8 @@ class OC_Template extends \OC\Template\Base {
|
||||||
* Includes another template. use <?php echo $this->inc('template'); ?> to
|
* Includes another template. use <?php echo $this->inc('template'); ?> to
|
||||||
* do this.
|
* do this.
|
||||||
*/
|
*/
|
||||||
public function inc( $file, $additionalparams = null ) {
|
public function inc( $file, $additionalParams = null ) {
|
||||||
return $this->load($this->path.$file.'.php', $additionalparams);
|
return $this->load($this->path.$file.'.php', $additionalParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -277,4 +277,34 @@ class OC_Template extends \OC\Template\Base {
|
||||||
$content->printPage();
|
$content->printPage();
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isAssetPipelineEnabled() {
|
||||||
|
// asset management enabled?
|
||||||
|
$useAssetPipeline = \OC::$server->getConfig()->getSystemValue('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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ class TemplateFileLocator {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $template
|
* @param string $template
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function find( $template ) {
|
public function find( $template ) {
|
||||||
if ($template === '') {
|
if ($template === '') {
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
use Assetic\Asset\AssetCollection;
|
use Assetic\Asset\AssetCollection;
|
||||||
use Assetic\Asset\FileAsset;
|
use Assetic\Asset\FileAsset;
|
||||||
use Assetic\AssetWriter;
|
use Assetic\AssetWriter;
|
||||||
use Assetic\Filter\CssRewriteFilter;
|
|
||||||
use Assetic\Filter\CssImportFilter;
|
use Assetic\Filter\CssImportFilter;
|
||||||
|
use Assetic\Filter\CssMinFilter;
|
||||||
|
use Assetic\Filter\CssRewriteFilter;
|
||||||
|
use Assetic\Filter\JSMinFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
|
* Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
|
||||||
|
@ -17,13 +19,22 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
private static $versionHash = '';
|
private static $versionHash = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $renderas
|
* @var \OCP\IConfig
|
||||||
* @param string $appid application id
|
|
||||||
*/
|
*/
|
||||||
public function __construct( $renderas, $appid = '' ) {
|
private $config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $renderAs
|
||||||
|
* @param string $appId application id
|
||||||
|
*/
|
||||||
|
public function __construct( $renderAs, $appId = '' ) {
|
||||||
|
|
||||||
|
// yes - should be injected ....
|
||||||
|
$this->config = \OC::$server->getConfig();
|
||||||
|
|
||||||
// Decide which page we show
|
// Decide which page we show
|
||||||
|
|
||||||
if( $renderas == 'user' ) {
|
if( $renderAs == 'user' ) {
|
||||||
parent::__construct( 'core', 'layout.user' );
|
parent::__construct( 'core', 'layout.user' );
|
||||||
if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
|
if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
|
||||||
$this->assign('bodyid', 'body-settings');
|
$this->assign('bodyid', 'body-settings');
|
||||||
|
@ -32,9 +43,12 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update notification
|
// Update notification
|
||||||
if(OC_Config::getValue('updatechecker', true) === true) {
|
if($this->config->getSystemValue('updatechecker', true) === true &&
|
||||||
$data=OC_Updater::check();
|
OC_User::isAdminUser(OC_User::getUser())) {
|
||||||
if(isset($data['version']) && $data['version'] != '' and $data['version'] !== Array() && OC_User::isAdminUser(OC_User::getUser())) {
|
$updater = new \OC\Updater();
|
||||||
|
$data = $updater->check('http://apps.owncloud.com/updater.php');
|
||||||
|
|
||||||
|
if(isset($data['version']) && $data['version'] != '' and $data['version'] !== Array()) {
|
||||||
$this->assign('updateAvailable', true);
|
$this->assign('updateAvailable', true);
|
||||||
$this->assign('updateVersion', $data['versionstring']);
|
$this->assign('updateVersion', $data['versionstring']);
|
||||||
$this->assign('updateLink', $data['web']);
|
$this->assign('updateLink', $data['web']);
|
||||||
|
@ -47,7 +61,7 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
|
|
||||||
// Add navigation entry
|
// Add navigation entry
|
||||||
$this->assign( 'application', '', false );
|
$this->assign( 'application', '', false );
|
||||||
$this->assign( 'appid', $appid );
|
$this->assign( 'appid', $appId );
|
||||||
$navigation = OC_App::getNavigation();
|
$navigation = OC_App::getNavigation();
|
||||||
$this->assign( 'navigation', $navigation);
|
$this->assign( 'navigation', $navigation);
|
||||||
$this->assign( 'settingsnavigation', OC_App::getSettingsNavigation());
|
$this->assign( 'settingsnavigation', OC_App::getSettingsNavigation());
|
||||||
|
@ -57,15 +71,15 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user_displayname = OC_User::getDisplayName();
|
$userDisplayName = OC_User::getDisplayName();
|
||||||
$this->assign( 'user_displayname', $user_displayname );
|
$this->assign( 'user_displayname', $userDisplayName );
|
||||||
$this->assign( 'user_uid', OC_User::getUser() );
|
$this->assign( 'user_uid', OC_User::getUser() );
|
||||||
$this->assign( 'appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0 );
|
$this->assign( 'appsmanagement_active', strpos(OC_Request::requestUri(), OC_Helper::linkToRoute('settings_apps')) === 0 );
|
||||||
$this->assign('enableAvatars', \OC_Config::getValue('enable_avatars', true));
|
$this->assign('enableAvatars', $this->config->getSystemValue('enable_avatars', true));
|
||||||
} else if ($renderas == 'error') {
|
} else if ($renderAs == 'error') {
|
||||||
parent::__construct('core', 'layout.guest', '', false);
|
parent::__construct('core', 'layout.guest', '', false);
|
||||||
$this->assign('bodyid', 'body-login');
|
$this->assign('bodyid', 'body-login');
|
||||||
} else if ($renderas == 'guest') {
|
} else if ($renderAs == 'guest') {
|
||||||
parent::__construct('core', 'layout.guest');
|
parent::__construct('core', 'layout.guest');
|
||||||
$this->assign('bodyid', 'body-login');
|
$this->assign('bodyid', 'body-login');
|
||||||
} else {
|
} else {
|
||||||
|
@ -76,27 +90,27 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
self::$versionHash = md5(implode(',', OC_App::getAppVersions()));
|
self::$versionHash = md5(implode(',', OC_App::getAppVersions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$useAssetPipeline = $this->isAssetPipelineEnabled();
|
$useAssetPipeline = self::isAssetPipelineEnabled();
|
||||||
if ($useAssetPipeline) {
|
if ($useAssetPipeline) {
|
||||||
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
|
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
|
||||||
$this->generateAssets();
|
$this->generateAssets();
|
||||||
} else {
|
} else {
|
||||||
// Add the js files
|
// Add the js files
|
||||||
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
|
$jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
|
||||||
$this->assign('jsfiles', array(), false);
|
$this->assign('jsfiles', array(), false);
|
||||||
if (OC_Config::getValue('installed', false) && $renderas!='error') {
|
if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
|
||||||
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
|
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash)));
|
||||||
}
|
}
|
||||||
foreach($jsfiles as $info) {
|
foreach($jsFiles as $info) {
|
||||||
$web = $info[1];
|
$web = $info[1];
|
||||||
$file = $info[2];
|
$file = $info[2];
|
||||||
$this->append( 'jsfiles', $web.'/'.$file . '?v=' . self::$versionHash);
|
$this->append( 'jsfiles', $web.'/'.$file . '?v=' . self::$versionHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the css files
|
// Add the css files
|
||||||
$cssfiles = self::findStylesheetFiles(OC_Util::$styles);
|
$cssFiles = self::findStylesheetFiles(OC_Util::$styles);
|
||||||
$this->assign('cssfiles', array());
|
$this->assign('cssfiles', array());
|
||||||
foreach($cssfiles as $info) {
|
foreach($cssFiles as $info) {
|
||||||
$web = $info[1];
|
$web = $info[1];
|
||||||
$file = $info[2];
|
$file = $info[2];
|
||||||
|
|
||||||
|
@ -113,10 +127,10 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
// Read the selected theme from the config file
|
// Read the selected theme from the config file
|
||||||
$theme = OC_Util::getTheme();
|
$theme = OC_Util::getTheme();
|
||||||
|
|
||||||
// Read the detected formfactor and use the right file name.
|
// Read the detected form factor and use the right file name.
|
||||||
$fext = self::getFormFactorExtension();
|
$formFactorExt = self::getFormFactorExtension();
|
||||||
|
|
||||||
$locator = new \OC\Template\CSSResourceLocator( $theme, $fext,
|
$locator = new \OC\Template\CSSResourceLocator( $theme, $formFactorExt,
|
||||||
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
||||||
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
||||||
$locator->find($styles);
|
$locator->find($styles);
|
||||||
|
@ -131,18 +145,17 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
// Read the selected theme from the config file
|
// Read the selected theme from the config file
|
||||||
$theme = OC_Util::getTheme();
|
$theme = OC_Util::getTheme();
|
||||||
|
|
||||||
// Read the detected formfactor and use the right file name.
|
// Read the detected form factor and use the right file name.
|
||||||
$fext = self::getFormFactorExtension();
|
$formFactorExt = self::getFormFactorExtension();
|
||||||
|
|
||||||
$locator = new \OC\Template\JSResourceLocator( $theme, $fext,
|
$locator = new \OC\Template\JSResourceLocator( $theme, $formFactorExt,
|
||||||
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
array( OC::$SERVERROOT => OC::$WEBROOT ),
|
||||||
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
array( OC::$THIRDPARTYROOT => OC::$THIRDPARTYWEBROOT ));
|
||||||
$locator->find($scripts);
|
$locator->find($scripts);
|
||||||
return $locator->getResources();
|
return $locator->getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateAssets()
|
public function generateAssets() {
|
||||||
{
|
|
||||||
$jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
|
$jsFiles = self::findJavascriptFiles(OC_Util::$scripts);
|
||||||
$jsHash = self::hashScriptNames($jsFiles);
|
$jsHash = self::hashScriptNames($jsFiles);
|
||||||
|
|
||||||
|
@ -150,7 +163,13 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
$jsFiles = array_map(function ($item) {
|
$jsFiles = array_map(function ($item) {
|
||||||
$root = $item[0];
|
$root = $item[0];
|
||||||
$file = $item[2];
|
$file = $item[2];
|
||||||
return new FileAsset($root . '/' . $file, array(), $root, $file);
|
// no need to minifiy minified files
|
||||||
|
if (substr($file, -strlen('.min.js')) === '.min.js') {
|
||||||
|
return new FileAsset($root . '/' . $file, array(), $root, $file);
|
||||||
|
}
|
||||||
|
return new FileAsset($root . '/' . $file, array(
|
||||||
|
new JSMinFilter()
|
||||||
|
), $root, $file);
|
||||||
}, $jsFiles);
|
}, $jsFiles);
|
||||||
$jsCollection = new AssetCollection($jsFiles);
|
$jsCollection = new AssetCollection($jsFiles);
|
||||||
$jsCollection->setTargetPath("assets/$jsHash.js");
|
$jsCollection->setTargetPath("assets/$jsHash.js");
|
||||||
|
@ -170,12 +189,13 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
$sourceRoot = \OC::$SERVERROOT;
|
$sourceRoot = \OC::$SERVERROOT;
|
||||||
$sourcePath = substr($assetPath, strlen(\OC::$SERVERROOT));
|
$sourcePath = substr($assetPath, strlen(\OC::$SERVERROOT));
|
||||||
return new FileAsset(
|
return new FileAsset(
|
||||||
$assetPath,
|
$assetPath,
|
||||||
array(
|
array(
|
||||||
new CssRewriteFilter(),
|
new CssRewriteFilter(),
|
||||||
|
new CssMinFilter(),
|
||||||
new CssImportFilter()
|
new CssImportFilter()
|
||||||
),
|
),
|
||||||
$sourceRoot,
|
$sourceRoot,
|
||||||
$sourcePath
|
$sourcePath
|
||||||
);
|
);
|
||||||
}, $cssFiles);
|
}, $cssFiles);
|
||||||
|
@ -194,8 +214,8 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
* @param array $files
|
* @param array $files
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private static function hashScriptNames($files)
|
private static function hashScriptNames($files) {
|
||||||
{
|
|
||||||
$files = array_map(function ($item) {
|
$files = array_map(function ($item) {
|
||||||
$root = $item[0];
|
$root = $item[0];
|
||||||
$file = $item[2];
|
$file = $item[2];
|
||||||
|
@ -204,36 +224,7 @@ class OC_TemplateLayout extends OC_Template {
|
||||||
|
|
||||||
sort($files);
|
sort($files);
|
||||||
// include the apps' versions hash to invalidate the cached assets
|
// include the apps' versions hash to invalidate the cached assets
|
||||||
$files[]= self::$versionHash;
|
$files[] = self::$versionHash;
|
||||||
return hash('md5', implode('', $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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2014 Thomas Müller <deepdiver@owncloud.com>
|
||||||
|
* This file is licensed under the Affero General Public License version 3 or
|
||||||
|
* later.
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OC\Repair;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||||
|
use OC\Hooks\BasicEmitter;
|
||||||
|
|
||||||
|
class AssetCache extends BasicEmitter implements \OC\RepairStep {
|
||||||
|
|
||||||
|
public function getName() {
|
||||||
|
return 'Clear asset cache after upgrade';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run() {
|
||||||
|
if (!\OC_Template::isAssetPipelineEnabled()) {
|
||||||
|
$this->emit('\OC\Repair', 'info', array('Asset pipeline disabled -> nothing to do'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$assetDir = \OC::$SERVERROOT . '/assets';
|
||||||
|
\OC_Helper::rmdirr($assetDir, false);
|
||||||
|
$this->emit('\OC\Repair', 'info', array('Asset cache cleared.'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue