diff --git a/core/img/filetypes/whiteboard.svg b/core/img/filetypes/whiteboard.svg new file mode 100644 index 0000000000000..0febec18004da --- /dev/null +++ b/core/img/filetypes/whiteboard.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/core/js/mimetype.js b/core/js/mimetype.js index 13a7ba6f6e53a..58f5575598cff 100644 --- a/core/js/mimetype.js +++ b/core/js/mimetype.js @@ -77,6 +77,7 @@ OC.MimeType = { while (mimeType in OC.MimeTypeList.aliases) { mimeType = OC.MimeTypeList.aliases[mimeType]; } + if (mimeType in OC.MimeType._mimeTypeIcons) { return OC.MimeType._mimeTypeIcons[mimeType]; } diff --git a/core/js/mimetypelist.js b/core/js/mimetypelist.js index 2e87ce756ba50..ac49a6c5c5d25 100644 --- a/core/js/mimetypelist.js +++ b/core/js/mimetypelist.js @@ -25,6 +25,7 @@ OC.MimeTypeList={ "application/postscript": "image", "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", + "application/vnd.excalidraw+json": "whiteboard", "application/vnd.lotus-wordpro": "x-office/document", "application/vnd.garmin.tcx+xml": "location", "application/vnd.google-earth.kml+xml": "location", @@ -139,6 +140,7 @@ OC.MimeTypeList={ "text-code", "text-vcard", "video", + "whiteboard", "x-office-document", "x-office-drawing", "x-office-form", diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php index 2d9072b999b75..6aee245291eaa 100644 --- a/lib/private/Repair/RepairMimeTypes.php +++ b/lib/private/Repair/RepairMimeTypes.php @@ -34,6 +34,8 @@ namespace OC\Repair; use OC\Migration\NullOutput; +use OCP\DB\Exception; +use OCP\DB\IResult; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IConfig; use OCP\IDBConnection; @@ -45,7 +47,7 @@ class RepairMimeTypes implements IRepairStep { private int $changeCount = 0; /** @var int */ - protected $folderMimeTypeId; + protected int $folderMimeTypeId; public function __construct( protected IConfig $config, @@ -53,15 +55,19 @@ public function __construct( ) { } - public function getName() { + public function getName(): string { return 'Repair mime types'; } - private function updateMimetypes($updatedMimetypes) { + /** + * @throws Exception + */ + private function updateMimetypes($updatedMimetypes): IResult|int|null { if ($this->dryRun) { $this->changeCount += count($updatedMimetypes); - return; + return null; } + $query = $this->connection->getQueryBuilder(); $query->select('id') ->from('mimetypes') @@ -109,7 +115,21 @@ private function updateMimetypes($updatedMimetypes) { return $count; } - private function introduceAsciidocType() { + /** + * @throws Exception + */ + private function introduceExcalidrawType(): IResult|int|null { + $updatedMimetypes = [ + 'excalidraw' => 'application/vnd.excalidraw+json', + ]; + + return $this->updateMimetypes($updatedMimetypes); + } + + /** + * @throws Exception + */ + private function introduceAsciidocType(): IResult|int|null { $updatedMimetypes = [ 'adoc' => 'text/asciidoc', 'asciidoc' => 'text/asciidoc', @@ -118,7 +138,10 @@ private function introduceAsciidocType() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceImageTypes() { + /** + * @throws Exception + */ + private function introduceImageTypes(): IResult|int|null { $updatedMimetypes = [ 'jp2' => 'image/jp2', 'webp' => 'image/webp', @@ -127,7 +150,10 @@ private function introduceImageTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceWindowsProgramTypes() { + /** + * @throws Exception + */ + private function introduceWindowsProgramTypes(): IResult|int|null { $updatedMimetypes = [ 'htaccess' => 'text/plain', 'bat' => 'application/x-msdos-program', @@ -137,7 +163,10 @@ private function introduceWindowsProgramTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceLocationTypes() { + /** + * @throws Exception + */ + private function introduceLocationTypes(): IResult|int|null { $updatedMimetypes = [ 'gpx' => 'application/gpx+xml', 'kml' => 'application/vnd.google-earth.kml+xml', @@ -148,7 +177,10 @@ private function introduceLocationTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceInternetShortcutTypes() { + /** + * @throws Exception + */ + private function introduceInternetShortcutTypes(): IResult|int|null { $updatedMimetypes = [ 'url' => 'application/internet-shortcut', 'webloc' => 'application/internet-shortcut' @@ -157,7 +189,10 @@ private function introduceInternetShortcutTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceStreamingTypes() { + /** + * @throws Exception + */ + private function introduceStreamingTypes(): IResult|int|null { $updatedMimetypes = [ 'm3u' => 'audio/mpegurl', 'm3u8' => 'audio/mpegurl', @@ -167,7 +202,10 @@ private function introduceStreamingTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceVisioTypes() { + /** + * @throws Exception + */ + private function introduceVisioTypes(): IResult|int|null { $updatedMimetypes = [ 'vsdm' => 'application/vnd.visio', 'vsdx' => 'application/vnd.visio', @@ -180,7 +218,10 @@ private function introduceVisioTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceComicbookTypes() { + /** + * @throws Exception + */ + private function introduceComicbookTypes(): IResult|int|null { $updatedMimetypes = [ 'cb7' => 'application/comicbook+7z', 'cba' => 'application/comicbook+ace', @@ -193,7 +234,10 @@ private function introduceComicbookTypes() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceOpenDocumentTemplates() { + /** + * @throws Exception + */ + private function introduceOpenDocumentTemplates(): IResult|int|null { $updatedMimetypes = [ 'ott' => 'application/vnd.oasis.opendocument.text-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', @@ -204,7 +248,10 @@ private function introduceOpenDocumentTemplates() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceFlatOpenDocumentType() { + /** + * @throws Exception + */ + private function introduceFlatOpenDocumentType(): IResult|int|null { $updatedMimetypes = [ "fodt" => "application/vnd.oasis.opendocument.text-flat-xml", "fods" => "application/vnd.oasis.opendocument.spreadsheet-flat-xml", @@ -215,7 +262,10 @@ private function introduceFlatOpenDocumentType() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceOrgModeType() { + /** + * @throws Exception + */ + private function introduceOrgModeType(): IResult|int|null { $updatedMimetypes = [ 'org' => 'text/org' ]; @@ -223,7 +273,10 @@ private function introduceOrgModeType() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceOnlyofficeFormType() { + /** + * @throws Exception + */ + private function introduceOnlyofficeFormType(): IResult|int|null { $updatedMimetypes = [ "oform" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", "docxf" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", @@ -232,7 +285,10 @@ private function introduceOnlyofficeFormType() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceEnhancedMetafileFormatType() { + /** + * @throws Exception + */ + private function introduceEnhancedMetafileFormatType(): IResult|int|null { $updatedMimetypes = [ 'emf' => 'image/emf', ]; @@ -240,7 +296,10 @@ private function introduceEnhancedMetafileFormatType() { return $this->updateMimetypes($updatedMimetypes); } - private function introduceEmlAndMsgFormatType() { + /** + * @throws Exception + */ + private function introduceEmlAndMsgFormatType(): IResult|int|null { $updatedMimetypes = [ 'eml' => 'message/rfc822', 'msg' => 'application/vnd.ms-outlook', @@ -249,6 +308,9 @@ private function introduceEmlAndMsgFormatType() { return $this->updateMimetypes($updatedMimetypes); } + /** + * @throws Exception + */ public function migrationsAvailable(): bool { $this->dryRun = true; $this->run(new NullOutput()); @@ -266,8 +328,10 @@ private function getMimeTypeVersion(): string { /** * Fix mime types + * + * @throws Exception */ - public function run(IOutput $out) { + public function run(IOutput $out): void { $serverVersion = $this->config->getSystemValueString('version', '0.0.0'); $mimeTypeVersion = $this->getMimeTypeVersion(); @@ -330,6 +394,10 @@ public function run(IOutput $out) { $out->info('Fixed eml and msg mime type'); } + if (version_compare($mimeTypeVersion, '30.0.0.0', '<') && $this->introduceExcalidrawType()) { + $out->info('Fixed Excalidraw mime type'); + } + if (!$this->dryRun) { $this->config->setAppValue('files', 'mimetype_version', $serverVersion); } diff --git a/resources/config/mimetypealiases.dist.json b/resources/config/mimetypealiases.dist.json index 6b0bcf3e59aba..5ef08e2fc39a7 100644 --- a/resources/config/mimetypealiases.dist.json +++ b/resources/config/mimetypealiases.dist.json @@ -26,6 +26,7 @@ "application/postscript": "image", "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", + "application/vnd.excalidraw+json": "whiteboard", "application/vnd.lotus-wordpro": "x-office/document", "application/vnd.garmin.tcx+xml": "location", "application/vnd.google-earth.kml+xml": "location", diff --git a/resources/config/mimetypemapping.dist.json b/resources/config/mimetypemapping.dist.json index c98e33756b667..d8723350d7cd6 100644 --- a/resources/config/mimetypemapping.dist.json +++ b/resources/config/mimetypemapping.dist.json @@ -58,6 +58,7 @@ "eps": ["application/postscript"], "epub": ["application/epub+zip"], "erf": ["image/x-dcraw"], + "excalidraw": ["application/vnd.excalidraw+json"], "exe": ["application/x-ms-dos-executable"], "fb2": ["application/x-fictionbook+xml", "text/plain"], "flac": ["audio/flac"], diff --git a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js index ffcf5e1fb1c7b..88ab500b75b13 100644 --- a/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js +++ b/tests/data/integritycheck/mimetypeListModified/core/js/mimetypelist.js @@ -26,6 +26,7 @@ OC.MimeTypeList={ "application/postscript": "image", "application/rss+xml": "application/xml", "application/vnd.android.package-archive": "package/x-generic", + "application/vnd.excalidraw+json": "whiteboard", "application/vnd.lotus-wordpro": "x-office/document", "application/vnd.garmin.tcx+xml": "location", "application/vnd.google-earth.kml+xml": "location", @@ -141,6 +142,7 @@ OC.MimeTypeList={ "text-code", "text-vcard", "video", + "whiteboard", "x-office-document", "x-office-drawing", "x-office-form", diff --git a/tests/data/integritycheck/mimetypeListModified/core/signature.json b/tests/data/integritycheck/mimetypeListModified/core/signature.json index 4ee844b87f8de..11a92ad9f7fb1 100644 --- a/tests/data/integritycheck/mimetypeListModified/core/signature.json +++ b/tests/data/integritycheck/mimetypeListModified/core/signature.json @@ -1,7 +1,7 @@ { "hashes": { - "core\/js\/mimetypelist.js": "e9e515c5eeb08b02971e5943640bef89b6d1c2d746d5883bf974c6ac753f810685c7a20bf0ed4d32d8c046cd2cef6c045682c7d89c6a3b7b6c33122f5fd2088f" + "core\/js\/mimetypelist.js": "abe5724362ef2a9f1ee549ff3e9a37e6a9438b5ebaafaa945e10eeb7fdad26f93b814ece0db43343a434fcc6bf26b59930b2c914f90611bcb29f746acf0c0aa4" }, - "signature": "iKEOaoY+lowIZrDjozpCqDFtag8qtANZ4AqnwZG1HrzuP3Yv7uaCUZbpsyr4FklKyyZFbh4w5K3x5bacKq\/h7tFVu5A56sunSZIMDjO\/ToGFYtZC59hTi0mKlmR+rIbAwmlm2Qad0uSD+\/4bkihL\/haPAtV8IbHXqxwjcYjkPmyi0W3rN1sOycgbH8Hmu7UlkdZORGTVVHdMpQuIljaBGBonQUTnqUb2BVsZ7YKW3Ls1AKMBam\/OGrB8rAJOht5b86qIE1jzzU\/BI7Qs+r8C+sh84LpLgz\/33njaBNANwfnvbrcb4f\/95BZCL4DcMGfwJ\/VNRVJrBjQSweYb+ypq5WMMOUvHHEg4CovoH\/XbdCAbRVet34vRZnZe5F4bXQOZXp0eqbqoY+STwQ5Ku2O7YUWwfppjxWMMfs1hDUrvvMBFRCd5mla\/aktV7ugishcZdKUFyDsyOEtT292Cb5f\/62RqnMniD9a+TOBE1qWH5DXYQqRO9TUdVtGQ3ITbLxEAzlfUmwYoXp+wgKbzOXC4KFzpxJnxHM+vuURkO5lUza68gqiG8\/uhNcPQufDT5CjasQVBTK5tdoL64UnXqATgU3rrD\/MByOXWlZvMsAS+NjPkF30UnvqgApEwytOlTZ27+ntZjfwhM3DlXNKE3mzUx+tvVfwBDmhEpBK\/Qpk6HLc=", + "signature": "JAEwvDOH764Q4LJJJpG77annu7EqnTUtSSWf2yL87S1BHaq5M9S7jQhJaowtoqiM4awH4uu\/KrKhqG\/YvpkKlL5I7Uluyrq7qJnYv3NDlnkc0oNlBdMLvgFbZHo8+MBFCoYo8BFuzNkgMQI7HTEg\/XYZErB9joCg40Ht502efHf5glUgDA0RU3fMKL0WJFaTeN\/oemKyqNKT5adtPjDzCd7Yk5dg32+oWnwHd5Cjt0lzzKUsvDVCIc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