Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing the Raw media types #14927

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/private/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
17 changes: 17 additions & 0 deletions lib/private/mimetypes.list.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'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),
Expand All @@ -47,12 +48,15 @@
'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),
Expand All @@ -62,6 +66,7 @@
'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),
Expand All @@ -72,11 +77,14 @@
'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),
Expand All @@ -87,6 +95,7 @@
'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),
Expand All @@ -95,6 +104,7 @@
'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),
Expand All @@ -104,10 +114,12 @@
'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),
Expand All @@ -125,11 +137,15 @@
'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),
Expand Down Expand Up @@ -158,5 +174,6 @@
'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),
);
30 changes: 29 additions & 1 deletion lib/repair/repairmimetypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,30 @@ private function fixPostscriptMimeType() {
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
*/
Expand All @@ -190,5 +214,9 @@ public function run() {
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'));
}
}
}
}
91 changes: 90 additions & 1 deletion tests/lib/repair/repairmimetypes.php
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -191,6 +191,61 @@ public function testRenamePostscriptMimeType() {
);
}

/**
* 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
Expand Down Expand Up @@ -301,6 +356,23 @@ public function testDoNothingWhenOnlyNewFiles() {
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'),
)
);

Expand All @@ -324,6 +396,23 @@ public function testDoNothingWhenOnlyNewFiles() {
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'),
)
);
}
Expand Down