[Pkg-owncloud-commits] [owncloud] 97/258: delete old previews
David Prévot
taffit at moszumanska.debian.org
Sat Oct 11 17:22:25 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit 645e7a0c9e1939816bdf592a966618c6d02e729a
Author: Georg Ehrke <developer at georgehrke.com>
Date: Sun Sep 21 17:16:21 2014 +0200
delete old previews
---
lib/private/repair.php | 12 +++++++++++-
lib/repair/preview.php | 32 ++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/lib/private/repair.php b/lib/private/repair.php
index 6cd24d6..6cdcc31 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -80,11 +80,21 @@ class Repair extends BasicEmitter {
* @return array of RepairStep instances
*/
public static function getBeforeUpgradeRepairSteps() {
- return array(
+ $steps = array(
new \OC\Repair\InnoDB(),
new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
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;
}
/**
diff --git a/lib/repair/preview.php b/lib/repair/preview.php
new file mode 100644
index 0000000..1216b3f
--- /dev/null
+++ b/lib/repair/preview.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Copyright (c) 2014 Georg Ehrke <georg at 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);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list