Merge pull request #11199 from owncloud/delete_bogus_previews

Delete bogus cached previews while updating
This commit is contained in:
Morris Jobke 2014-09-21 22:48:21 +02:00
commit 154e848ce2
2 changed files with 43 additions and 1 deletions

View File

@ -82,11 +82,21 @@ class Repair extends BasicEmitter {
* @return array of RepairStep instances * @return array of RepairStep instances
*/ */
public static function getBeforeUpgradeRepairSteps() { public static function getBeforeUpgradeRepairSteps() {
return array( $steps = array(
new \OC\Repair\InnoDB(), new \OC\Repair\InnoDB(),
new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()), new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
new \OC\Repair\SearchLuceneTables() new \OC\Repair\SearchLuceneTables()
); );
//There is no need to delete all previews on every single update
//only 7.0.0 thru 7.0.2 generated broken previews
$currentVersion = \OC_Config::getValue('version');
if (version_compare($currentVersion, '7.0.0.0', '>=') &&
version_compare($currentVersion, '7.0.2.2', '<=')) {
$steps[] = new \OC\Repair\Preview();
}
return $steps;
} }
/** /**

32
lib/repair/preview.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* Copyright (c) 2014 Georg Ehrke <georg@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 OC\Files\View;
use OC\Hooks\BasicEmitter;
class Preview extends BasicEmitter implements \OC\RepairStep {
public function getName() {
return 'Cleaning-up broken previews';
}
public function run() {
$view = new View('/');
$children = $view->getDirectoryContent('/');
foreach ($children as $child) {
if ($view->is_dir($child->getPath())) {
$thumbnailsFolder = $child->getPath() . '/thumbnails';
if ($view->is_dir($thumbnailsFolder)) {
$view->rmdir($thumbnailsFolder);
}
}
}
}
}