]> source.dussan.org Git - nextcloud-server.git/commitdiff
Introducing the Raw mimetypes
authorOlivier Paroz <github@oparoz.com>
Mon, 16 Mar 2015 15:25:04 +0000 (16:25 +0100)
committerOlivier Paroz <github@oparoz.com>
Mon, 16 Mar 2015 15:25:04 +0000 (16:25 +0100)
lib/private/helper.php
lib/private/mimetypes.list.php
lib/repair/repairmimetypes.php
tests/lib/repair/repairmimetypes.php

index ebc30395a6b984855dcbd26097878b7694dc4657..0925c2367cd83b1d775149cb6af5cf17bd12a4a1 100644 (file)
@@ -39,6 +39,7 @@ class OC_Helper {
                'application/coreldraw' => 'image',
                'application/x-gimp' => 'image',
                'application/x-photoshop' => 'image',
+               'application/x-dcraw' => 'image',
 
                'application/font-sfnt' => 'font',
                'application/x-font' => 'font',
index 265fffa7db3ed205f1eff0f530c7659ade4f11ee..c051c0eded22e0ee42159e48b4a0969e35fe525d 100644 (file)
@@ -33,6 +33,7 @@ return array(
        'accdb' => array('application/msaccess', null),
        'ai' => array('application/illustrator', null),
        'apk' => array('application/vnd.android.package-archive', null),
+       'arw' => array('image/x-dcraw', null),
        'avi' => array('video/x-msvideo', null),
        'bash' => array('text/x-shellscript', null),
        'blend' => array('application/x-blender', null),
@@ -47,12 +48,15 @@ return array(
        'cc' => array('text/x-c', null),
        'cdr' => array('application/coreldraw', null),
        'cpp' => array('text/x-c++src', null),
+       'cr2' => array('image/x-dcraw', null),
        'css' => array('text/css', null),
        'csv' => array('text/csv', null),
        'cvbdl' => array('application/x-cbr', null),
        'c' => array('text/x-c', null),
        'c++' => array('text/x-c++src', null),
+       'dcr' => array('image/x-dcraw', null),
        'deb' => array('application/x-deb', null),
+       'dng' => array('image/x-dcraw', null),
        'doc' => array('application/msword', null),
        'docm' => array('application/vnd.ms-word.document.macroEnabled.12', null),
        'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', null),
@@ -62,6 +66,7 @@ return array(
        'eot' => array('application/vnd.ms-fontobject', null),
        'epub' => array('application/epub+zip', null),
        'eps' => array('application/postscript', null),
+       'erf' => array('image/x-dcraw', null),
        'exe' => array('application/x-ms-dos-executable', null),
        'flac' => array('audio/flac', null),
        'flv' => array('video/x-flv', null),
@@ -72,11 +77,14 @@ return array(
        'htm' => array('text/html', 'text/plain'),
        'ical' => array('text/calendar', null),
        'ics' => array('text/calendar', null),
+       'iiq' => array('image/x-dcraw', null),
        'impress' => array('text/impress', null),
        'jpeg' => array('image/jpeg', null),
        'jpg' => array('image/jpeg', null),
        'js' => array('application/javascript', 'text/plain'),
        'json' => array('application/json', 'text/plain'),
+       'k25' => array('image/x-dcraw', null),
+       'kdc' => array('image/x-dcraw', null),
        'key' => array('application/x-iwork-keynote-sffkey', null),
        'keynote' => array('application/x-iwork-keynote-sffkey', null),
        'kra' => array('application/x-krita', null),
@@ -87,6 +95,7 @@ return array(
        'md' => array('text/markdown', null),
        'mdb' => array('application/msaccess', null),
        'mdwn' => array('text/markdown', null),
+       'mef' => array('image/x-dcraw', null),
        'mkv' => array('video/x-matroska', null),
        'mobi' => array('application/x-mobipocket-ebook', null),
        'mov' => array('video/quicktime', null),
@@ -95,6 +104,7 @@ return array(
        'mpeg' => array('video/mpeg', null),
        'mpg' => array('video/mpeg', null),
        'msi' => array('application/x-msi', null),
+       'nef' => array('image/x-dcraw', null),
        'numbers' => array('application/x-iwork-numbers-sffnumbers', null),
        'odf' => array('application/vnd.oasis.opendocument.formula', null),
        'odg' => array('application/vnd.oasis.opendocument.graphics', null),
@@ -104,10 +114,12 @@ return array(
        'oga' => array('audio/ogg', null),
        'ogg' => array('audio/ogg', null),
        'ogv' => array('video/ogg', null),
+       'orf' => array('image/x-dcraw', null),
        'otf' => array('application/font-sfnt', null),
        'pages' => array('application/x-iwork-pages-sffpages', null),
        'pdf' => array('application/pdf', null),
        'pfb' => array('application/x-font', null),
+       'pef' => array('image/x-dcraw', null),
        'php' => array('application/x-php', null),
        'pl' => array('application/x-perl', null),
        'png' => array('image/png', null),
@@ -125,11 +137,15 @@ return array(
        'ps' => array('application/postscript', null),
        'psd' => array('application/x-photoshop', null),
        'py' => array('text/x-python', null),
+       'raf' => array('image/x-dcraw', null),
        'rar' => array('application/x-rar-compressed', null),
        'reveal' => array('text/reveal', null),
+       'rw2' => array('image/x-dcraw', null),
        'sgf' => array('application/sgf', null),
        'sh-lib' => array('text/x-shellscript', null),
        'sh' => array('text/x-shellscript', null),
+       'srf' => array('image/x-dcraw', null),
+       'sr2' => array('image/x-dcraw', null),
        'svg' => array('image/svg+xml', 'text/plain'),
        'swf' => array('application/x-shockwave-flash', 'application/octet-stream'),
        'tar' => array('application/x-tar', null),
@@ -158,5 +174,6 @@ return array(
        'xltm' => array('application/vnd.ms-excel.template.macroEnabled.12', null),
        'xltx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.template', null),
        'xml' => array('application/xml', 'text/plain'),
+       'xrf' => array('image/x-dcraw', null),
        'zip' => array('application/zip', null),
 );
index 06cd144bff411a2eac1a115ff3bf2d18704b28d4..ad55c63c21a7e95f41e339060939797a1c6bf18c 100644 (file)
@@ -171,6 +171,30 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
                self::updateMimetypes($updatedMimetypes);
        }
 
+       private function introduceRawMimeType() {
+               $updatedMimetypes = array(
+                       'arw' => 'image/x-dcraw',
+                       'cr2' => 'image/x-dcraw',
+                       'dcr' => 'image/x-dcraw',
+                       'dng' => 'image/x-dcraw',
+                       'erf' => 'image/x-dcraw',
+                       'iiq' => 'image/x-dcraw',
+                       'k25' => 'image/x-dcraw',
+                       'kdc' => 'image/x-dcraw',
+                       'mef' => 'image/x-dcraw',
+                       'nef' => 'image/x-dcraw',
+                       'orf' => 'image/x-dcraw',
+                       'pef' => 'image/x-dcraw',
+                       'raf' => 'image/x-dcraw',
+                       'rw2' => 'image/x-dcraw',
+                       'srf' => 'image/x-dcraw',
+                       'sr2' => 'image/x-dcraw',
+                       'xrf' => 'image/x-dcraw',
+               );
+
+               self::updateMimetypes($updatedMimetypes);
+       }
+
        /**
         * Fix mime types
         */
@@ -190,5 +214,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
                if ($this->fixPostscriptMimeType()) {
                        $this->emit('\OC\Repair', 'info', array('Fixed Postscript mime types'));
                }
+
+               if ($this->introduceRawMimeType()) {
+                       $this->emit('\OC\Repair', 'info', array('Fixed Raw mime types'));
+               }
        }
-}
\ No newline at end of file
+}
index 403474957f15bc03ab1ae4ccecb0df32041b1e22..839a4723ecd7939bbe9d44dd830990bb7646aa0d 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
  * Copyright (c) 2014 Vincent Petry <pvince81@owncloud.com>
- * Copyright (c) 2014 Olivier Paroz owncloud@oparoz.com
+ * Copyright (c) 2014-2015 Olivier Paroz owncloud@oparoz.com
  * This file is licensed under the Affero General Public License version 3 or
  * later.
  * See the COPYING-README file.
@@ -191,6 +191,61 @@ class TestRepairMimeTypes extends \Test\TestCase {
                );
        }
 
+       /**
+        * Test renaming the postscript mime types
+        */
+       public function testRenameRawMimeType() {
+               $this->addEntries(
+                       array(
+                               array('test.arw', 'application/octet-stream'),
+                               array('test.cr2', 'application/octet-stream'),
+                               array('test.dcr', 'application/octet-stream'),
+                               array('test.dng', 'application/octet-stream'),
+                               array('test.erf', 'application/octet-stream'),
+                               array('test.iiq', 'application/octet-stream'),
+                               array('test.k25', 'application/octet-stream'),
+                               array('test.kdc', 'application/octet-stream'),
+                               array('test.mef', 'application/octet-stream'),
+                               array('test.nef', 'application/octet-stream'),
+                               array('test.orf', 'application/octet-stream'),
+                               array('test.pef', 'application/octet-stream'),
+                               array('test.raf', 'application/octet-stream'),
+                               array('test.rw2', 'application/octet-stream'),
+                               array('test.srf', 'application/octet-stream'),
+                               array('test.sr2', 'application/octet-stream'),
+                               array('test.xrf', 'application/octet-stream'),
+                       )
+               );
+
+               $this->repair->run();
+
+               // force mimetype reload
+               DummyFileCache::clearCachedMimeTypes();
+               $this->storage->getCache()->loadMimeTypes();
+
+               $this->checkEntries(
+                       array(
+                               array('test.arw', 'image/x-dcraw'),
+                               array('test.cr2', 'image/x-dcraw'),
+                               array('test.dcr', 'image/x-dcraw'),
+                               array('test.dng', 'image/x-dcraw'),
+                               array('test.erf', 'image/x-dcraw'),
+                               array('test.iiq', 'image/x-dcraw'),
+                               array('test.k25', 'image/x-dcraw'),
+                               array('test.kdc', 'image/x-dcraw'),
+                               array('test.mef', 'image/x-dcraw'),
+                               array('test.nef', 'image/x-dcraw'),
+                               array('test.orf', 'image/x-dcraw'),
+                               array('test.pef', 'image/x-dcraw'),
+                               array('test.raf', 'image/x-dcraw'),
+                               array('test.rw2', 'image/x-dcraw'),
+                               array('test.srf', 'image/x-dcraw'),
+                               array('test.sr2', 'image/x-dcraw'),
+                               array('test.xrf', 'image/x-dcraw'),
+                       )
+               );
+       }
+
        /**
         * Test renaming and splitting old office mime types when
         * new ones already exist
@@ -301,6 +356,23 @@ class TestRepairMimeTypes extends \Test\TestCase {
                                array('test.pfb', 'application/x-font'),
                                array('test.eps', 'application/postscript'),
                                array('test.ps', 'application/postscript'),
+                               array('test.arw', 'image/x-dcraw'),
+                               array('test.cr2', 'image/x-dcraw'),
+                               array('test.dcr', 'image/x-dcraw'),
+                               array('test.dng', 'image/x-dcraw'),
+                               array('test.erf', 'image/x-dcraw'),
+                               array('test.iiq', 'image/x-dcraw'),
+                               array('test.k25', 'image/x-dcraw'),
+                               array('test.kdc', 'image/x-dcraw'),
+                               array('test.mef', 'image/x-dcraw'),
+                               array('test.nef', 'image/x-dcraw'),
+                               array('test.orf', 'image/x-dcraw'),
+                               array('test.pef', 'image/x-dcraw'),
+                               array('test.raf', 'image/x-dcraw'),
+                               array('test.rw2', 'image/x-dcraw'),
+                               array('test.srf', 'image/x-dcraw'),
+                               array('test.sr2', 'image/x-dcraw'),
+                               array('test.xrf', 'image/x-dcraw'),
                        )
                );
 
@@ -324,6 +396,23 @@ class TestRepairMimeTypes extends \Test\TestCase {
                                array('test.pfb', 'application/x-font'),
                                array('test.eps', 'application/postscript'),
                                array('test.ps', 'application/postscript'),
+                               array('test.arw', 'image/x-dcraw'),
+                               array('test.cr2', 'image/x-dcraw'),
+                               array('test.dcr', 'image/x-dcraw'),
+                               array('test.dng', 'image/x-dcraw'),
+                               array('test.erf', 'image/x-dcraw'),
+                               array('test.iiq', 'image/x-dcraw'),
+                               array('test.k25', 'image/x-dcraw'),
+                               array('test.kdc', 'image/x-dcraw'),
+                               array('test.mef', 'image/x-dcraw'),
+                               array('test.nef', 'image/x-dcraw'),
+                               array('test.orf', 'image/x-dcraw'),
+                               array('test.pef', 'image/x-dcraw'),
+                               array('test.raf', 'image/x-dcraw'),
+                               array('test.rw2', 'image/x-dcraw'),
+                               array('test.srf', 'image/x-dcraw'),
+                               array('test.sr2', 'image/x-dcraw'),
+                               array('test.xrf', 'image/x-dcraw'),
                        )
                );
        }