From 4dfaa5e69ace071f2917a8417103ac8ddcd496b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 5 Dec 2022 14:54:13 +0000 Subject: [PATCH 1/4] Fix mimetype size --- app/config/collections.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/config/collections.php b/app/config/collections.php index bdc14d9105..e872953568 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3256,7 +3256,7 @@ $collections = [ '$id' => ID::custom('mimeType'), 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 127, // https://tools.ietf.org/html/rfc4288#section-4.2 + 'size' => 255, // https://tools.ietf.org/html/rfc4288#section-4.2 'signed' => true, 'required' => false, 'default' => null, From ea58cb4aff4dab9936042ab1d79ac88de8c4cbff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 5 Dec 2022 14:57:24 +0000 Subject: [PATCH 2/4] Update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 0ba56af243..e9b8ed761f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ - Fix invited account verified status [#4776](https://github.com/appwrite/appwrite/pull/4776) - Get default region from environment on project create [#4780](https://github.com/appwrite/appwrite/pull/4780) +- Fix max mimetype size [#4814](https://github.com/appwrite/appwrite/pull/4814) # Version 1.1.2 ## Changes From 0a177713f06c54a4107f0b90ac3a1ce5d6de4485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 7 Dec 2022 11:01:58 +0000 Subject: [PATCH 3/4] Implement migration for mimeType --- src/Appwrite/Migration/Migration.php | 1 + src/Appwrite/Migration/Version/V17.php | 79 ++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/Appwrite/Migration/Version/V17.php diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index bef6e5e603..b764641279 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -48,6 +48,7 @@ abstract class Migration '1.1.0' => 'V16', '1.1.1' => 'V16', '1.1.2' => 'V16', + '1.2.0' => 'V17', ]; /** diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php new file mode 100644 index 0000000000..b04aa2a7c3 --- /dev/null +++ b/src/Appwrite/Migration/Version/V17.php @@ -0,0 +1,79 @@ + null, + fn () => [] + ); + } + + Console::log('Migrating Project: ' . $this->project->getAttribute('name') . ' (' . $this->project->getId() . ')'); + + Console::info('Migrating Collections'); + $this->migrateCollections(); + + // Console::info('Migrating Documents'); + // $this->forEachDocument([$this, 'fixDocument']); + } + + /** + * Migrate all Collections. + * + * @return void + */ + protected function migrateCollections(): void + { + foreach ($this->collections as $collection) { + $id = $collection['$id']; + + Console::log("Migrating Collection \"{$id}\""); + + $this->projectDB->setNamespace("_{$this->project->getInternalId()}"); + + switch ($id) { + case 'files': + try { + /** + * Update 'mimeType' attribute size (127->255) + */ + $this->projectDB->updateAttribute($id, 'mimeType', Database::VAR_STRING, 255, true, false); + } catch (\Throwable $th) { + Console::warning("'mimeType' from {$id}: {$th->getMessage()}"); + } + + break; + + default: + break; + } + + usleep(50000); + } + } + + /** + * Fix run on each document + * + * @param \Utopia\Database\Document $document + * @return \Utopia\Database\Document + */ + protected function fixDocument(Document $document) + { + return $document; + } +} From 4ee8fd5629e01547e042cc449cde130860bbd30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 16 Dec 2022 10:39:53 +0100 Subject: [PATCH 4/4] Add cache clean --- src/Appwrite/Migration/Version/V17.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index b04aa2a7c3..66a02662d1 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -52,6 +52,7 @@ class V17 extends Migration * Update 'mimeType' attribute size (127->255) */ $this->projectDB->updateAttribute($id, 'mimeType', Database::VAR_STRING, 255, true, false); + $this->projectDB->deleteCachedCollection($id); } catch (\Throwable $th) { Console::warning("'mimeType' from {$id}: {$th->getMessage()}"); }