diff options
author | Normal Ra <normalraw@gmail.com> | 2014-08-12 14:07:10 +0200 |
---|---|---|
committer | Normal Ra <normalraw@gmail.com> | 2014-08-12 14:07:10 +0200 |
commit | 38498af17146f42ac42f9eb119d5642bfd522a09 (patch) | |
tree | ae8babb4c7f839db74c30cd7c7922875a74d0be6 /lib | |
parent | 42edd5b788dd98da02e3c14751a40cc44b081b4b (diff) | |
download | nextcloud-server-38498af17146f42ac42f9eb119d5642bfd522a09.tar.gz nextcloud-server-38498af17146f42ac42f9eb119d5642bfd522a09.zip |
Add APK mimetype repair scenario.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repair/repairmimetypes.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/repair/repairmimetypes.php b/lib/repair/repairmimetypes.php index f7618c6e060..00f5340a878 100644 --- a/lib/repair/repairmimetypes.php +++ b/lib/repair/repairmimetypes.php @@ -113,6 +113,44 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { } } + private function fixAPKMimeType() { + $existsStmt = \OC_DB::prepare(' + SELECT count(`mimetype`) + FROM `*PREFIX*mimetypes` + WHERE `mimetype` = ? + '); + + $insertStmt = \OC_DB::prepare(' + INSERT INTO `*PREFIX*mimetypes` ( `mimetype` ) + VALUES ( ? ) + '); + + + $updateByNameStmt = \OC_DB::prepare(' + UPDATE `*PREFIX*filecache` + SET `mimetype` = ( + SELECT `id` + FROM `*PREFIX*mimetypes` + WHERE `mimetype` = ? + ) WHERE `name` LIKE ? + '); + + + $mimeTypeExtension = 'apk'; + $mimeTypeName = 'application/vnd.android.package-archive'; + + $result = \OC_DB::executeAudited($existsStmt, array($mimeTypeName)); + $exists = $result->fetchOne(); + + if ( ! $exists ) { + // insert mimetype + \OC_DB::executeAudited($insertStmt, array($mimeTypeName)); + } + + // change mimetype for files with x extension + \OC_DB::executeAudited($updateByNameStmt, array($mimeTypeName, '%.'.$mimeTypeExtension)); + } + /** * Fix mime types */ @@ -120,6 +158,10 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep { if ($this->fixOfficeMimeTypes()) { $this->emit('\OC\Repair', 'info', array('Fixed office mime types')); } + + if ($this->fixAPKMimeType()) { + $this->emit('\OC\Repair', 'info', array('Fixed APK mime type')); + } } } |