summaryrefslogtreecommitdiffstats
path: root/apps/files/appinfo
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-06-06 12:29:43 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-06-06 12:29:43 +0200
commit204eb256f39e2aaedd0b416f25573a9abb822eac (patch)
tree41502fdf5473dc08aa2910976f1dfa7d60e0ca29 /apps/files/appinfo
parentc47d4ebbac7885ad91cf56355bd6aa09318ff8e8 (diff)
parent7af67eb6301dffb1c65dbe42a1af6352a6f04510 (diff)
downloadnextcloud-server-204eb256f39e2aaedd0b416f25573a9abb822eac.tar.gz
nextcloud-server-204eb256f39e2aaedd0b416f25573a9abb822eac.zip
Merge pull request #8895 from owncloud/mimetype_fixes
add more and fix office mimetypes, migrate wrong mimetypes
Diffstat (limited to 'apps/files/appinfo')
-rw-r--r--apps/files/appinfo/update.php57
-rw-r--r--apps/files/appinfo/version2
2 files changed, 58 insertions, 1 deletions
diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php
index de635e5ce6b..a9b8ccbf824 100644
--- a/apps/files/appinfo/update.php
+++ b/apps/files/appinfo/update.php
@@ -6,3 +6,60 @@ if (version_compare(\OCP\Config::getSystemValue('version', '0.0.0'), '7.0.0', '<
\OCP\Config::deleteSystemValue('allowZipDownload');
\OCP\Config::deleteSystemValue('maxZipInputSize');
}
+
+if (version_compare(\OCP\Config::getAppValue('files', 'installed_version'), '1.1.9', '<')) {
+
+ // update wrong mimetypes
+ $wrongMimetypes = array(
+ 'application/mspowerpoint' => 'application/vnd.ms-powerpoint',
+ 'application/msexcel' => 'application/vnd.ms-excel',
+ );
+
+ $stmt = OC_DB::prepare('
+ UPDATE `*PREFIX*mimetypes`
+ SET `mimetype` = ?
+ WHERE `mimetype` = ?
+ ');
+
+ foreach ($wrongMimetypes as $wrong => $correct) {
+ OC_DB::executeAudited($stmt, array($wrong, $correct));
+ }
+
+ $updatedMimetypes = array(
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'xlsx' => 'application/vnd.ms-excel',
+ 'pptx' => 'application/vnd.ms-powerpoint',
+ );
+
+ // separate doc from docx etc
+ foreach ($updatedMimetypes as $extension => $mimetype ) {
+ $result = OC_DB::executeAudited('
+ SELECT count(`mimetype`)
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ', array($mimetype)
+ );
+
+ $exists = $result->fetchOne();
+
+ if ( ! $exists ) {
+ // insert mimetype
+ OC_DB::executeAudited('
+ INSERT INTO `*PREFIX*mimetypes` ( `mimetype` )
+ VALUES ( ? )
+ ', array($mimetype)
+ );
+ }
+
+ // change mimetype for files with x extension
+ OC_DB::executeAudited('
+ UPDATE `*PREFIX*filecache`
+ SET `mimetype` = (
+ SELECT `id`
+ FROM `*PREFIX*mimetypes`
+ WHERE `mimetype` = ?
+ ) WHERE `name` LIKE ?
+ ', array($mimetype, '%.'.$extension)
+ );
+ }
+} \ No newline at end of file
diff --git a/apps/files/appinfo/version b/apps/files/appinfo/version
index 18efdb9ae67..512a1faa680 100644
--- a/apps/files/appinfo/version
+++ b/apps/files/appinfo/version
@@ -1 +1 @@
-1.1.8
+1.1.9