aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Repair/RepairMimeTypes.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Repair/RepairMimeTypes.php')
-rw-r--r--lib/private/Repair/RepairMimeTypes.php133
1 files changed, 98 insertions, 35 deletions
diff --git a/lib/private/Repair/RepairMimeTypes.php b/lib/private/Repair/RepairMimeTypes.php
index 2eece761c8d..3c9720b9e91 100644
--- a/lib/private/Repair/RepairMimeTypes.php
+++ b/lib/private/Repair/RepairMimeTypes.php
@@ -10,6 +10,7 @@ use OC\Migration\NullOutput;
use OCP\DB\Exception;
use OCP\DB\IResult;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\Migration\IOutput;
@@ -24,7 +25,8 @@ class RepairMimeTypes implements IRepairStep {
public function __construct(
protected IConfig $config,
- protected IDBConnection $connection
+ protected IAppConfig $appConfig,
+ protected IDBConnection $connection,
) {
}
@@ -58,6 +60,7 @@ class RepairMimeTypes implements IRepairStep {
$update = $this->connection->getQueryBuilder();
$update->update('filecache')
+ ->runAcrossAllShards()
->set('mimetype', $update->createParameter('mimetype'))
->where($update->expr()->neq('mimetype', $update->createParameter('mimetype'), IQueryBuilder::PARAM_INT))
->andWhere($update->expr()->neq('mimetype', $update->createParameter('folder'), IQueryBuilder::PARAM_INT))
@@ -90,29 +93,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @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',
- ];
-
- return $this->updateMimetypes($updatedMimetypes);
- }
-
- /**
- * @throws Exception
+ * @since 12.0.0.14
*/
private function introduceImageTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -125,6 +106,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 12.0.0.13
*/
private function introduceWindowsProgramTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -138,6 +120,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 13.0.0.0
*/
private function introduceLocationTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -152,6 +135,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 13.0.0.3
*/
private function introduceInternetShortcutTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -164,6 +148,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 13.0.0.6
*/
private function introduceStreamingTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -177,6 +162,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 14.0.0.8
*/
private function introduceVisioTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -193,6 +179,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 14.0.0.10
*/
private function introduceComicbookTypes(): IResult|int|null {
$updatedMimetypes = [
@@ -209,6 +196,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 20.0.0.5
*/
private function introduceOpenDocumentTemplates(): IResult|int|null {
$updatedMimetypes = [
@@ -223,13 +211,11 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 21.0.0.7
*/
- private function introduceFlatOpenDocumentType(): IResult|int|null {
+ private function introduceOrgModeType(): IResult|int|null {
$updatedMimetypes = [
- "fodt" => "application/vnd.oasis.opendocument.text-flat-xml",
- "fods" => "application/vnd.oasis.opendocument.spreadsheet-flat-xml",
- "fodg" => "application/vnd.oasis.opendocument.graphics-flat-xml",
- "fodp" => "application/vnd.oasis.opendocument.presentation-flat-xml",
+ 'org' => 'text/org'
];
return $this->updateMimetypes($updatedMimetypes);
@@ -237,10 +223,14 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 23.0.0.2
*/
- private function introduceOrgModeType(): IResult|int|null {
+ private function introduceFlatOpenDocumentType(): IResult|int|null {
$updatedMimetypes = [
- 'org' => 'text/org'
+ 'fodt' => 'application/vnd.oasis.opendocument.text-flat-xml',
+ 'fods' => 'application/vnd.oasis.opendocument.spreadsheet-flat-xml',
+ 'fodg' => 'application/vnd.oasis.opendocument.graphics-flat-xml',
+ 'fodp' => 'application/vnd.oasis.opendocument.presentation-flat-xml',
];
return $this->updateMimetypes($updatedMimetypes);
@@ -248,11 +238,25 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 25.0.0.2
*/
private function introduceOnlyofficeFormType(): IResult|int|null {
$updatedMimetypes = [
- "oform" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform",
- "docxf" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf",
+ 'oform' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform',
+ 'docxf' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf',
+ ];
+
+ return $this->updateMimetypes($updatedMimetypes);
+ }
+
+ /**
+ * @throws Exception
+ * @since 26.0.0.1
+ */
+ private function introduceAsciidocType(): IResult|int|null {
+ $updatedMimetypes = [
+ 'adoc' => 'text/asciidoc',
+ 'asciidoc' => 'text/asciidoc',
];
return $this->updateMimetypes($updatedMimetypes);
@@ -260,6 +264,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 28.0.0.5
*/
private function introduceEnhancedMetafileFormatType(): IResult|int|null {
$updatedMimetypes = [
@@ -271,6 +276,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 29.0.0.2
*/
private function introduceEmlAndMsgFormatType(): IResult|int|null {
$updatedMimetypes = [
@@ -283,6 +289,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 29.0.0.6
*/
private function introduceAacAudioType(): IResult|int|null {
$updatedMimetypes = [
@@ -294,6 +301,7 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 29.0.10
*/
private function introduceReStructuredTextFormatType(): IResult|int|null {
$updatedMimetypes = [
@@ -305,6 +313,49 @@ class RepairMimeTypes implements IRepairStep {
/**
* @throws Exception
+ * @since 30.0.0
+ */
+ private function introduceExcalidrawType(): IResult|int|null {
+ $updatedMimetypes = [
+ 'excalidraw' => 'application/vnd.excalidraw+json',
+ ];
+
+ return $this->updateMimetypes($updatedMimetypes);
+ }
+
+
+ /**
+ * @throws Exception
+ * @since 31.0.0
+ */
+ private function introduceZstType(): IResult|int|null {
+ $updatedMimetypes = [
+ 'zst' => 'application/zstd',
+ 'nfo' => 'text/x-nfo',
+ ];
+
+ return $this->updateMimetypes($updatedMimetypes);
+ }
+
+ /**
+ * @throws Exception
+ * @since 32.0.0
+ */
+ private function introduceMusicxmlType(): IResult|int|null {
+ $updatedMimetypes = [
+ 'mxl' => 'application/vnd.recordare.musicxml',
+ 'musicxml' => 'application/vnd.recordare.musicxml+xml',
+ ];
+
+ return $this->updateMimetypes($updatedMimetypes);
+ }
+
+
+
+ /**
+ * Check if there are any migrations available
+ *
+ * @throws Exception
*/
public function migrationsAvailable(): bool {
$this->dryRun = true;
@@ -313,11 +364,14 @@ class RepairMimeTypes implements IRepairStep {
return $this->changeCount > 0;
}
+ /**
+ * Get the current mimetype version
+ */
private function getMimeTypeVersion(): string {
$serverVersion = $this->config->getSystemValueString('version', '0.0.0');
// 29.0.0.10 is the last version with a mimetype migration before it was moved to a separate version number
if (version_compare($serverVersion, '29.0.0.10', '>')) {
- return $this->config->getAppValue('files', 'mimetype_version', '29.0.0.10');
+ return $this->appConfig->getValueString('files', 'mimetype_version', '29.0.0.10');
}
return $serverVersion;
@@ -334,6 +388,7 @@ class RepairMimeTypes implements IRepairStep {
// NOTE TO DEVELOPERS: when adding new mime types, please make sure to
// add a version comparison to avoid doing it every time
+ // PLEASE ALSO KEEP THE LIST SORTED BY VERSION NUMBER
if (version_compare($mimeTypeVersion, '12.0.0.14', '<') && $this->introduceImageTypes()) {
$out->info('Fixed image mime types');
@@ -403,8 +458,16 @@ class RepairMimeTypes implements IRepairStep {
$out->info('Fixed Excalidraw mime type');
}
+ if (version_compare($mimeTypeVersion, '31.0.0.0', '<') && $this->introduceZstType()) {
+ $out->info('Fixed zst mime type');
+ }
+
+ if (version_compare($mimeTypeVersion, '32.0.0.0', '<') && $this->introduceMusicxmlType()) {
+ $out->info('Fixed musicxml mime type');
+ }
+
if (!$this->dryRun) {
- $this->config->setAppValue('files', 'mimetype_version', $serverVersion);
+ $this->appConfig->setValueString('files', 'mimetype_version', $serverVersion);
}
}
}