Merge pull request #15088 from oparoz/3d-support
Introducing 3D images support (media type)
This commit is contained in:
commit
21bc8e0c81
|
@ -81,6 +81,7 @@ return array(
|
|||
'impress' => array('text/impress', null),
|
||||
'jpeg' => array('image/jpeg', null),
|
||||
'jpg' => array('image/jpeg', null),
|
||||
'jps' => array('image/jpeg', null),
|
||||
'js' => array('application/javascript', 'text/plain'),
|
||||
'json' => array('application/json', 'text/plain'),
|
||||
'k25' => array('image/x-dcraw', null),
|
||||
|
@ -103,6 +104,7 @@ return array(
|
|||
'mp4' => array('video/mp4', null),
|
||||
'mpeg' => array('video/mpeg', null),
|
||||
'mpg' => array('video/mpeg', null),
|
||||
'mpo' => array('image/jpeg', null),
|
||||
'msi' => array('application/x-msi', null),
|
||||
'nef' => array('image/x-dcraw', null),
|
||||
'numbers' => array('application/x-iwork-numbers-sffnumbers', null),
|
||||
|
|
|
@ -17,7 +17,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
public function getName() {
|
||||
return 'Repair mime types';
|
||||
}
|
||||
|
||||
|
||||
private static function existsStmt() {
|
||||
return \OC_DB::prepare('
|
||||
SELECT count(`mimetype`)
|
||||
|
@ -51,14 +51,14 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
) WHERE `mimetype` = ?
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
private static function deleteStmt() {
|
||||
return \OC_DB::prepare('
|
||||
DELETE FROM `*PREFIX*mimetypes`
|
||||
WHERE `id` = ?
|
||||
');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static function updateByNameStmt() {
|
||||
return \OC_DB::prepare('
|
||||
UPDATE `*PREFIX*filecache`
|
||||
|
@ -69,7 +69,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
) WHERE `name` ILIKE ?
|
||||
');
|
||||
}
|
||||
|
||||
|
||||
private function repairMimetypes($wrongMimetypes) {
|
||||
foreach ($wrongMimetypes as $wrong => $correct) {
|
||||
// do we need to remove a wrong mimetype?
|
||||
|
@ -81,8 +81,8 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
$result = \OC_DB::executeAudited(self::existsStmt(), array($correct));
|
||||
$exists = $result->fetchOne();
|
||||
|
||||
if ( ! is_null($correct) ) {
|
||||
if ( ! $exists ) {
|
||||
if (!is_null($correct)) {
|
||||
if (!$exists) {
|
||||
// insert mimetype
|
||||
\OC_DB::executeAudited(self::insertStmt(), array($correct));
|
||||
}
|
||||
|
@ -90,27 +90,27 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
// change wrong mimetype to correct mimetype in filecache
|
||||
\OC_DB::executeAudited(self::updateWrongStmt(), array($correct, $wrongId));
|
||||
}
|
||||
|
||||
|
||||
// delete wrong mimetype
|
||||
\OC_DB::executeAudited(self::deleteStmt(), array($wrongId));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function updateMimetypes($updatedMimetypes) {
|
||||
|
||||
foreach ($updatedMimetypes as $extension => $mimetype ) {
|
||||
|
||||
foreach ($updatedMimetypes as $extension => $mimetype) {
|
||||
$result = \OC_DB::executeAudited(self::existsStmt(), array($mimetype));
|
||||
$exists = $result->fetchOne();
|
||||
|
||||
if ( ! $exists ) {
|
||||
if (!$exists) {
|
||||
// insert mimetype
|
||||
\OC_DB::executeAudited(self::insertStmt(), array($mimetype));
|
||||
}
|
||||
|
||||
// change mimetype for files with x extension
|
||||
\OC_DB::executeAudited(self::updateByNameStmt(), array($mimetype, '%.'.$extension));
|
||||
\OC_DB::executeAudited(self::updateByNameStmt(), array($mimetype, '%.' . $extension));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,9 +132,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
|
||||
// separate doc from docx etc
|
||||
self::updateMimetypes($updatedMimetypes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function fixApkMimeType() {
|
||||
$updatedMimetypes = array(
|
||||
'apk' => 'application/vnd.android.package-archive',
|
||||
|
@ -142,7 +142,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
|
||||
self::updateMimetypes($updatedMimetypes);
|
||||
}
|
||||
|
||||
|
||||
private function fixFontsMimeTypes() {
|
||||
// update wrong mimetypes
|
||||
$wrongMimetypes = array(
|
||||
|
@ -152,7 +152,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
);
|
||||
|
||||
self::repairMimetypes($wrongMimetypes);
|
||||
|
||||
|
||||
$updatedMimetypes = array(
|
||||
'ttf' => 'application/font-sfnt',
|
||||
'otf' => 'application/font-sfnt',
|
||||
|
@ -161,7 +161,7 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
|
||||
self::updateMimetypes($updatedMimetypes);
|
||||
}
|
||||
|
||||
|
||||
private function fixPostscriptMimeType() {
|
||||
$updatedMimetypes = array(
|
||||
'eps' => 'application/postscript',
|
||||
|
@ -195,6 +195,15 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
self::updateMimetypes($updatedMimetypes);
|
||||
}
|
||||
|
||||
private function introduce3dImagesMimeType() {
|
||||
$updatedMimetypes = array(
|
||||
'jps' => 'image/jpeg',
|
||||
'mpo' => 'image/jpeg',
|
||||
);
|
||||
|
||||
self::updateMimetypes($updatedMimetypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix mime types
|
||||
*/
|
||||
|
@ -202,15 +211,15 @@ 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'));
|
||||
}
|
||||
|
||||
|
||||
if ($this->fixFontsMimeTypes()) {
|
||||
$this->emit('\OC\Repair', 'info', array('Fixed fonts mime types'));
|
||||
}
|
||||
|
||||
|
||||
if ($this->fixPostscriptMimeType()) {
|
||||
$this->emit('\OC\Repair', 'info', array('Fixed Postscript mime types'));
|
||||
}
|
||||
|
@ -218,5 +227,9 @@ class RepairMimeTypes extends BasicEmitter implements \OC\RepairStep {
|
|||
if ($this->introduceRawMimeType()) {
|
||||
$this->emit('\OC\Repair', 'info', array('Fixed Raw mime types'));
|
||||
}
|
||||
|
||||
if ($this->introduce3dImagesMimeType()) {
|
||||
$this->emit('\OC\Repair', 'info', array('Fixed 3D images mime types'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->storage = new \OC\Files\Storage\Temporary(array());
|
||||
$this->storage = new \OC\Files\Storage\Temporary([]);
|
||||
|
||||
$this->repair = new \OC\Repair\RepairMimeTypes();
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
protected function tearDown() {
|
||||
$this->storage->getCache()->clear();
|
||||
$sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
|
||||
\OC_DB::executeAudited($sql, array($this->storage->getId()));
|
||||
\OC_DB::executeAudited($sql, [$this->storage->getId()]);
|
||||
$this->clearMimeTypes();
|
||||
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
|
@ -48,11 +48,11 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
foreach ($entries as $entry) {
|
||||
$this->storage->getCache()->put(
|
||||
$entry[0],
|
||||
array(
|
||||
[
|
||||
'size' => 0,
|
||||
'mtime' => 0,
|
||||
'mimetype' => $entry[1]
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
*/
|
||||
private function getMimeTypeIdFromDB($mimeType) {
|
||||
$sql = 'SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?';
|
||||
$results = \OC_DB::executeAudited($sql, array($mimeType));
|
||||
$results = \OC_DB::executeAudited($sql, [$mimeType]);
|
||||
$result = $results->fetchOne();
|
||||
if ($result) {
|
||||
return $result['id'];
|
||||
|
@ -79,173 +79,159 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
return null;
|
||||
}
|
||||
|
||||
private function renameMimeTypes($currentMimeTypes, $fixedMimeTypes) {
|
||||
$this->addEntries($currentMimeTypes);
|
||||
|
||||
$this->repair->run();
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries($fixedMimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test renaming and splitting old office mime types
|
||||
*/
|
||||
public function testRenameOfficeMimeTypes() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/msword'),
|
||||
array('test.xls', 'application/msexcel'),
|
||||
array('test.xlsx', 'application/msexcel'),
|
||||
array('test.ppt', 'application/mspowerpoint'),
|
||||
array('test.pptx', 'application/mspowerpoint'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/msword'],
|
||||
['test.xls', 'application/msexcel'],
|
||||
['test.xlsx', 'application/msexcel'],
|
||||
['test.ppt', 'application/mspowerpoint'],
|
||||
['test.pptx', 'application/mspowerpoint'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['test.xls', 'application/vnd.ms-excel'],
|
||||
['test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['test.ppt', 'application/vnd.ms-powerpoint'],
|
||||
['test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('test.xls', 'application/vnd.ms-excel'),
|
||||
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('test.ppt', 'application/vnd.ms-powerpoint'),
|
||||
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test renaming old fonts mime types
|
||||
*/
|
||||
public function testRenameFontsMimeTypes() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.ttf', 'application/x-font-ttf'),
|
||||
array('test.otf', 'font/opentype'),
|
||||
array('test.pfb', 'application/octet-stream'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.ttf', 'application/x-font-ttf'],
|
||||
['test.otf', 'font/opentype'],
|
||||
['test.pfb', 'application/octet-stream'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.ttf', 'application/font-sfnt'],
|
||||
['test.otf', 'application/font-sfnt'],
|
||||
['test.pfb', 'application/x-font'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.ttf', 'application/font-sfnt'),
|
||||
array('test.otf', 'application/font-sfnt'),
|
||||
array('test.pfb', 'application/x-font'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test renaming the APK mime type
|
||||
*/
|
||||
public function testRenameAPKMimeType() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.apk', 'application/octet-stream'),
|
||||
array('bogus.apk', 'application/vnd.android.package-archive'),
|
||||
array('bogus2.apk', 'application/wrong'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.apk', 'application/octet-stream'],
|
||||
['bogus.apk', 'application/vnd.android.package-archive'],
|
||||
['bogus2.apk', 'application/wrong'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.apk', 'application/vnd.android.package-archive'],
|
||||
['bogus.apk', 'application/vnd.android.package-archive'],
|
||||
['bogus2.apk', 'application/vnd.android.package-archive'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.apk', 'application/vnd.android.package-archive'),
|
||||
array('bogus.apk', 'application/vnd.android.package-archive'),
|
||||
array('bogus2.apk', 'application/vnd.android.package-archive'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test renaming the postscript mime types
|
||||
*/
|
||||
public function testRenamePostscriptMimeType() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.eps', 'application/octet-stream'),
|
||||
array('test.ps', 'application/octet-stream'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.eps', 'application/octet-stream'],
|
||||
['test.ps', 'application/octet-stream'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.eps', 'application/postscript'],
|
||||
['test.ps', 'application/postscript'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.eps', 'application/postscript'),
|
||||
array('test.ps', 'application/postscript'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test renaming the Raw 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'),
|
||||
array('CapitalExtension.DNG', 'application/octet-stream'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.arw', 'application/octet-stream'],
|
||||
['test.cr2', 'application/octet-stream'],
|
||||
['test.dcr', 'application/octet-stream'],
|
||||
['test.dng', 'application/octet-stream'],
|
||||
['test.erf', 'application/octet-stream'],
|
||||
['test.iiq', 'application/octet-stream'],
|
||||
['test.k25', 'application/octet-stream'],
|
||||
['test.kdc', 'application/octet-stream'],
|
||||
['test.mef', 'application/octet-stream'],
|
||||
['test.nef', 'application/octet-stream'],
|
||||
['test.orf', 'application/octet-stream'],
|
||||
['test.pef', 'application/octet-stream'],
|
||||
['test.raf', 'application/octet-stream'],
|
||||
['test.rw2', 'application/octet-stream'],
|
||||
['test.srf', 'application/octet-stream'],
|
||||
['test.sr2', 'application/octet-stream'],
|
||||
['test.xrf', 'application/octet-stream'],
|
||||
['CapitalExtension.DNG', 'application/octet-stream'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.arw', 'image/x-dcraw'],
|
||||
['test.cr2', 'image/x-dcraw'],
|
||||
['test.dcr', 'image/x-dcraw'],
|
||||
['test.dng', 'image/x-dcraw'],
|
||||
['test.erf', 'image/x-dcraw'],
|
||||
['test.iiq', 'image/x-dcraw'],
|
||||
['test.k25', 'image/x-dcraw'],
|
||||
['test.kdc', 'image/x-dcraw'],
|
||||
['test.mef', 'image/x-dcraw'],
|
||||
['test.nef', 'image/x-dcraw'],
|
||||
['test.orf', 'image/x-dcraw'],
|
||||
['test.pef', 'image/x-dcraw'],
|
||||
['test.raf', 'image/x-dcraw'],
|
||||
['test.rw2', 'image/x-dcraw'],
|
||||
['test.srf', 'image/x-dcraw'],
|
||||
['test.sr2', 'image/x-dcraw'],
|
||||
['test.xrf', 'image/x-dcraw'],
|
||||
['CapitalExtension.DNG', 'image/x-dcraw'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
$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'),
|
||||
array('CapitalExtension.DNG', 'image/x-dcraw'),
|
||||
)
|
||||
);
|
||||
public function testRename3dImagesMimeType() {
|
||||
$currentMimeTypes = [
|
||||
['test.eps', 'application/octet-stream'],
|
||||
['test.ps', 'application/octet-stream'],
|
||||
];
|
||||
|
||||
$fixedMimeTypes = [
|
||||
['test.eps', 'application/postscript'],
|
||||
['test.ps', 'application/postscript'],
|
||||
];
|
||||
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,85 +239,69 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
* new ones already exist
|
||||
*/
|
||||
public function testRenameOfficeMimeTypesWhenExist() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/msword'),
|
||||
array('test.xls', 'application/msexcel'),
|
||||
array('test.xlsx', 'application/msexcel'),
|
||||
array('test.ppt', 'application/mspowerpoint'),
|
||||
array('test.pptx', 'application/mspowerpoint'),
|
||||
// make it so that the new mimetypes already exist
|
||||
array('bogus.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('bogus.xlsx', 'application/vnd.ms-excel'),
|
||||
array('bogus.pptx', 'application/vnd.ms-powerpoint'),
|
||||
array('bogus2.docx', 'application/wrong'),
|
||||
array('bogus2.xlsx', 'application/wrong'),
|
||||
array('bogus2.pptx', 'application/wrong'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/msword'],
|
||||
['test.xls', 'application/msexcel'],
|
||||
['test.xlsx', 'application/msexcel'],
|
||||
['test.ppt', 'application/mspowerpoint'],
|
||||
['test.pptx', 'application/mspowerpoint'],
|
||||
// make it so that the new mimetypes already exist
|
||||
['bogus.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['bogus.xlsx', 'application/vnd.ms-excel'],
|
||||
['bogus.pptx', 'application/vnd.ms-powerpoint'],
|
||||
['bogus2.docx', 'application/wrong'],
|
||||
['bogus2.xlsx', 'application/wrong'],
|
||||
['bogus2.pptx', 'application/wrong'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['test.xls', 'application/vnd.ms-excel'],
|
||||
['test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['test.ppt', 'application/vnd.ms-powerpoint'],
|
||||
['test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
['bogus.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['bogus.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['bogus.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
['bogus2.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['bogus2.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['bogus2.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('test.xls', 'application/vnd.ms-excel'),
|
||||
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('test.ppt', 'application/vnd.ms-powerpoint'),
|
||||
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
array('bogus.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('bogus.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('bogus.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
array('bogus2.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('bogus2.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('bogus2.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
|
||||
// wrong mimetypes are gone
|
||||
$this->assertNull($this->getMimeTypeIdFromDB('application/msexcel'));
|
||||
$this->assertNull($this->getMimeTypeIdFromDB('application/mspowerpoint'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test renaming old fonts mime types when
|
||||
* new ones already exist
|
||||
*/
|
||||
public function testRenameFontsMimeTypesWhenExist() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.ttf', 'application/x-font-ttf'),
|
||||
array('test.otf', 'font/opentype'),
|
||||
// make it so that the new mimetypes already exist
|
||||
array('bogus.ttf', 'application/font-sfnt'),
|
||||
array('bogus.otf', 'application/font-sfnt'),
|
||||
array('bogus2.ttf', 'application/wrong'),
|
||||
array('bogus2.otf', 'application/wrong'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.ttf', 'application/x-font-ttf'],
|
||||
['test.otf', 'font/opentype'],
|
||||
// make it so that the new mimetypes already exist
|
||||
['bogus.ttf', 'application/font-sfnt'],
|
||||
['bogus.otf', 'application/font-sfnt'],
|
||||
['bogus2.ttf', 'application/wrong'],
|
||||
['bogus2.otf', 'application/wrong'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.ttf', 'application/font-sfnt'],
|
||||
['test.otf', 'application/font-sfnt'],
|
||||
['bogus.ttf', 'application/font-sfnt'],
|
||||
['bogus.otf', 'application/font-sfnt'],
|
||||
['bogus2.ttf', 'application/font-sfnt'],
|
||||
['bogus2.otf', 'application/font-sfnt'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.ttf', 'application/font-sfnt'),
|
||||
array('test.otf', 'application/font-sfnt'),
|
||||
array('bogus.ttf', 'application/font-sfnt'),
|
||||
array('bogus.otf', 'application/font-sfnt'),
|
||||
array('bogus2.ttf', 'application/font-sfnt'),
|
||||
array('bogus2.otf', 'application/font-sfnt'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
|
||||
// wrong mimetypes are gone
|
||||
$this->assertNull($this->getMimeTypeIdFromDB('application/x-font-ttf'));
|
||||
|
@ -344,81 +314,77 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
* already correct and no old ones exist..
|
||||
*/
|
||||
public function testDoNothingWhenOnlyNewFiles() {
|
||||
$this->addEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('test.xls', 'application/vnd.ms-excel'),
|
||||
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('test.ppt', 'application/vnd.ms-powerpoint'),
|
||||
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
array('test.apk', 'application/vnd.android.package-archive'),
|
||||
array('test.ttf', 'application/font-sfnt'),
|
||||
array('test.otf', 'application/font-sfnt'),
|
||||
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'),
|
||||
array('test.DNG', 'image/x-dcraw'),
|
||||
)
|
||||
);
|
||||
$currentMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['test.xls', 'application/vnd.ms-excel'],
|
||||
['test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['test.ppt', 'application/vnd.ms-powerpoint'],
|
||||
['test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
['test.apk', 'application/vnd.android.package-archive'],
|
||||
['test.ttf', 'application/font-sfnt'],
|
||||
['test.otf', 'application/font-sfnt'],
|
||||
['test.pfb', 'application/x-font'],
|
||||
['test.eps', 'application/postscript'],
|
||||
['test.ps', 'application/postscript'],
|
||||
['test.arw', 'image/x-dcraw'],
|
||||
['test.cr2', 'image/x-dcraw'],
|
||||
['test.dcr', 'image/x-dcraw'],
|
||||
['test.dng', 'image/x-dcraw'],
|
||||
['test.erf', 'image/x-dcraw'],
|
||||
['test.iiq', 'image/x-dcraw'],
|
||||
['test.k25', 'image/x-dcraw'],
|
||||
['test.kdc', 'image/x-dcraw'],
|
||||
['test.mef', 'image/x-dcraw'],
|
||||
['test.nef', 'image/x-dcraw'],
|
||||
['test.orf', 'image/x-dcraw'],
|
||||
['test.pef', 'image/x-dcraw'],
|
||||
['test.raf', 'image/x-dcraw'],
|
||||
['test.rw2', 'image/x-dcraw'],
|
||||
['test.srf', 'image/x-dcraw'],
|
||||
['test.sr2', 'image/x-dcraw'],
|
||||
['test.xrf', 'image/x-dcraw'],
|
||||
['test.DNG', 'image/x-dcraw'],
|
||||
['test.jps', 'image/jpeg'],
|
||||
['test.MPO', 'image/jpeg'],
|
||||
];
|
||||
|
||||
$this->repair->run();
|
||||
$fixedMimeTypes = [
|
||||
['test.doc', 'application/msword'],
|
||||
['test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
||||
['test.xls', 'application/vnd.ms-excel'],
|
||||
['test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
||||
['test.ppt', 'application/vnd.ms-powerpoint'],
|
||||
['test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
||||
['test.apk', 'application/vnd.android.package-archive'],
|
||||
['test.ttf', 'application/font-sfnt'],
|
||||
['test.otf', 'application/font-sfnt'],
|
||||
['test.pfb', 'application/x-font'],
|
||||
['test.eps', 'application/postscript'],
|
||||
['test.ps', 'application/postscript'],
|
||||
['test.arw', 'image/x-dcraw'],
|
||||
['test.cr2', 'image/x-dcraw'],
|
||||
['test.dcr', 'image/x-dcraw'],
|
||||
['test.dng', 'image/x-dcraw'],
|
||||
['test.erf', 'image/x-dcraw'],
|
||||
['test.iiq', 'image/x-dcraw'],
|
||||
['test.k25', 'image/x-dcraw'],
|
||||
['test.kdc', 'image/x-dcraw'],
|
||||
['test.mef', 'image/x-dcraw'],
|
||||
['test.nef', 'image/x-dcraw'],
|
||||
['test.orf', 'image/x-dcraw'],
|
||||
['test.pef', 'image/x-dcraw'],
|
||||
['test.raf', 'image/x-dcraw'],
|
||||
['test.rw2', 'image/x-dcraw'],
|
||||
['test.srf', 'image/x-dcraw'],
|
||||
['test.sr2', 'image/x-dcraw'],
|
||||
['test.xrf', 'image/x-dcraw'],
|
||||
['test.DNG', 'image/x-dcraw'],
|
||||
['test.jps', 'image/jpeg'],
|
||||
['test.MPO', 'image/jpeg'],
|
||||
];
|
||||
|
||||
// force mimetype reload
|
||||
DummyFileCache::clearCachedMimeTypes();
|
||||
$this->storage->getCache()->loadMimeTypes();
|
||||
|
||||
$this->checkEntries(
|
||||
array(
|
||||
array('test.doc', 'application/msword'),
|
||||
array('test.docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'),
|
||||
array('test.xls', 'application/vnd.ms-excel'),
|
||||
array('test.xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'),
|
||||
array('test.ppt', 'application/vnd.ms-powerpoint'),
|
||||
array('test.pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
|
||||
array('test.apk', 'application/vnd.android.package-archive'),
|
||||
array('test.ttf', 'application/font-sfnt'),
|
||||
array('test.otf', 'application/font-sfnt'),
|
||||
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'),
|
||||
array('test.DNG', 'image/x-dcraw'),
|
||||
)
|
||||
);
|
||||
$this->renameMimeTypes($currentMimeTypes, $fixedMimeTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,8 +394,8 @@ class TestRepairMimeTypes extends \Test\TestCase {
|
|||
class DummyFileCache extends \OC\Files\Cache\Cache {
|
||||
|
||||
public static function clearCachedMimeTypes() {
|
||||
self::$mimetypeIds = array();
|
||||
self::$mimetypes = array();
|
||||
self::$mimetypeIds = [];
|
||||
self::$mimetypes = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue