Merge pull request #14927 from oparoz/raw-mimetypes

Introducing the Raw media types
This commit is contained in:
Thomas Müller 2015-03-17 11:32:09 +01:00
commit 98a42dbccc
4 changed files with 137 additions and 2 deletions

View 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',

View 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),
);

View 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'));
}
}
}
}

View 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'),
)
);
}