Reduce amount of rows to update

This commit is contained in:
Victor Dubiniuk 2015-06-09 01:02:26 +03:00
parent 429bd7ce37
commit 262d7e659d
1 changed files with 6 additions and 6 deletions

View File

@ -76,11 +76,8 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
private static function updateByNameStmt() {
return \OC_DB::prepare('
UPDATE `*PREFIX*filecache`
SET `mimetype` = (
SELECT `id`
FROM `*PREFIX*mimetypes`
WHERE `mimetype` = ?
) WHERE `name` ILIKE ?
SET `mimetype` = ?
WHERE `mimetype` <> ? AND `name` ILIKE ?
');
}
@ -123,8 +120,11 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
\OC_DB::executeAudited(self::insertStmt(), array($mimetype));
}
// get target mimetype id
$mimetypeId = \OC_DB::executeAudited(self::getIdStmt(), array($mimetype));
// change mimetype for files with x extension
\OC_DB::executeAudited(self::updateByNameStmt(), array($mimetype, '%.' . $extension));
\OC_DB::executeAudited(self::updateByNameStmt(), array($mimetypeId, $mimetypeId, '%.' . $extension));
}
}