summaryrefslogtreecommitdiffstats
path: root/lib/repair
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-10-09 18:16:36 +0200
committerVincent Petry <pvince81@owncloud.com>2015-10-12 17:28:32 +0200
commit37747016f2ec7e26a05af3ec68236793789218a5 (patch)
treea66ff1df7f90de6fa52fa6291346451084ab709f /lib/repair
parent07f903a1e3204318346bb0c011ee373e879c5cfb (diff)
downloadnextcloud-server-37747016f2ec7e26a05af3ec68236793789218a5.tar.gz
nextcloud-server-37747016f2ec7e26a05af3ec68236793789218a5.zip
Do not update mime types for folders with extension
Some folders might have an extension like "test.conf". This fix prevents to overwrite the folder's mime type with another mime type while running the mimetype repair step.
Diffstat (limited to 'lib/repair')
-rw-r--r--lib/repair/repairmimetypes.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php
index 89ad0ed16c7..c26faddb4dd 100644
--- a/lib/repair/repairmimetypes.php
+++ b/lib/repair/repairmimetypes.php
@@ -29,6 +29,10 @@ namespace OC\Repair;
use OC\Hooks\BasicEmitter;
class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
+ /**
+ * @var int
+ */
+ protected $folderMimeTypeId;
public function getName() {
return 'Repair mime types';
@@ -79,7 +83,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
return \OC_DB::prepare('
UPDATE `*PREFIX*filecache`
SET `mimetype` = ?
- WHERE `mimetype` <> ? AND `name` ILIKE ?
+ WHERE `mimetype` <> ? AND `mimetype` <> ? AND `name` ILIKE ?
');
}
@@ -112,6 +116,10 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
}
private function updateMimetypes($updatedMimetypes) {
+ if (empty($this->folderMimeTypeId)) {
+ $result = \OC_DB::executeAudited(self::getIdStmt(), array('httpd/unix-directory'));
+ $this->folderMimeTypeId = (int)$result->fetchOne();
+ }
foreach ($updatedMimetypes as $extension => $mimetype) {
$result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype));
@@ -127,7 +135,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
$mimetypeId = $result->fetchOne();
// change mimetype for files with x extension
- \OC_DB::executeAudited(self::updateByNameStmt(), array($mimetypeId, $mimetypeId, '%.' . $extension));
+ \OC_DB::executeAudited(self::updateByNameStmt(), array($mimetypeId, $this->folderMimeTypeId, $mimetypeId, '%.' . $extension));
}
}