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-09 18:16:36 +0200
commit8098c06e708ba24a5beccd7a85572c7990c9a3f5 (patch)
treeffff07cfc6909afe090ae798439d94b827740a3c /lib/repair
parent18ad60380cdd5c5e346f6b2a8dfbef0a204e00b2 (diff)
downloadnextcloud-server-8098c06e708ba24a5beccd7a85572c7990c9a3f5.tar.gz
nextcloud-server-8098c06e708ba24a5beccd7a85572c7990c9a3f5.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.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php
index aeac69d00db..3ea9e45816e 100644
--- a/lib/repair/repairmimetypes.php
+++ b/lib/repair/repairmimetypes.php
@@ -36,6 +36,11 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
protected $config;
/**
+ * @var int
+ */
+ protected $folderMimeTypeId;
+
+ /**
* @param \OCP\IConfig $config
*/
public function __construct($config) {
@@ -91,7 +96,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 ?
');
}
@@ -124,6 +129,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));
@@ -139,7 +148,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));
}
}