[Pkg-owncloud-commits] [owncloud] 61/258: repair search lucene before installing
David Prévot
taffit at moszumanska.debian.org
Sat Oct 11 17:22:21 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 463ad5a50d313ff57ce28ba13b63e64d5a37c8b7
Author: Jörn Friedrich Dreyer <jfd at butonic.de>
Date: Tue Sep 9 15:18:57 2014 +0200
repair search lucene before installing
---
lib/private/repair.php | 3 +-
lib/repair/innodb.php | 2 +-
lib/repair/searchlucenetables.php | 63 +++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 2 deletions(-)
diff --git a/lib/private/repair.php b/lib/private/repair.php
index e6943c5..6cd24d6 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -82,7 +82,8 @@ class Repair extends BasicEmitter {
public static function getBeforeUpgradeRepairSteps() {
return array(
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()
);
}
diff --git a/lib/repair/innodb.php b/lib/repair/innodb.php
index 6b795a7..0e13c30 100644
--- a/lib/repair/innodb.php
+++ b/lib/repair/innodb.php
@@ -23,7 +23,7 @@ class InnoDB extends BasicEmitter implements \OC\RepairStep {
public function run() {
$connection = \OC_DB::getConnection();
if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) {
- $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to no'));
+ $this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do'));
return;
}
diff --git a/lib/repair/searchlucenetables.php b/lib/repair/searchlucenetables.php
new file mode 100644
index 0000000..32231e9
--- /dev/null
+++ b/lib/repair/searchlucenetables.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Copyright (c) 2014 Jörn Friedrich Dreyer <jfd 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\Hooks\BasicEmitter;
+
+class SearchLuceneTables extends BasicEmitter implements \OC\RepairStep {
+
+ public function getName() {
+ return 'Repair duplicate entries in oc_lucene_status';
+ }
+
+ /**
+ * Fix duplicate entries in oc_lucene_status
+ *
+ * search_lucene prior to v0.5.0 did not have a primary key on the lucene_status table. Newer versions do, which
+ * causes the migration check to fail because it tries to insert duplicate rows into the new schema.
+ *
+ * FIXME Currently, apps don't have a way of repairing anything before the migration check:
+ * @link https://github.com/owncloud/core/issues/10980
+ *
+ * As a result this repair step needs to live in the core repo, although it belongs into search_lucene:
+ * @link https://github.com/owncloud/core/issues/10205#issuecomment-54957557
+ *
+ * It will completely remove any rows that make a file id have more than one status:
+ * fileid | status fileid | status
+ * --------+-------- will become --------+--------
+ * 2 | E 3 | E
+ * 2 | I
+ * 3 | E
+ *
+ * search_lucene will then reindex the fileids without a status when the next indexing job is executed
+ */
+ public function run() {
+ if (\OC_DB::tableExists('lucene_status')) {
+ $this->emit('\OC\Repair', 'info', array('removing duplicate entries from lucene_status'));
+
+ $connection = \OC_DB::getConnection();
+ $query = $connection->prepare('
+ DELETE FROM `*PREFIX*lucene_status`
+ WHERE `fileid` IN (
+ SELECT `fileid`
+ FROM (
+ SELECT `fileid`
+ FROM `*PREFIX*lucene_status`
+ GROUP BY `fileid`
+ HAVING count(`fileid`) > 1
+ ) AS `mysqlerr1093hack`
+ )');
+ $query->execute();
+ } else {
+ $this->emit('\OC\Repair', 'info', array('lucene_status table does not exist -> nothing to do'));
+ }
+ }
+
+}
+
--
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