From d664549495a999ed5927c4b3292275acd1e07426 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 10 Nov 2022 13:48:55 +0000 Subject: [PATCH 1/4] fix: use getDevice in deletes worker --- app/workers/deletes.php | 12 ++-- composer.lock | 139 +++++++++++++++++++++++++++++----------- 2 files changed, 106 insertions(+), 45 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index b015043b1..c4512adf2 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -259,8 +259,8 @@ class DeletesV1 extends Worker $this->getProjectDB($projectId)->delete($projectId); // Delete all storage directories - $uploads = new Local(APP_STORAGE_UPLOADS . '/app-' . $document->getId()); - $cache = new Local(APP_STORAGE_CACHE . '/app-' . $document->getId()); + $uploads = $this->getDevice(APP_STORAGE_UPLOADS . '/app-' . $document->getId()); + $cache = $this->getDevice(APP_STORAGE_CACHE . '/app-' . $document->getId()); $uploads->delete($uploads->getRoot(), true); $cache->delete($cache->getRoot(), true); @@ -425,7 +425,7 @@ class DeletesV1 extends Worker * Delete Deployments */ Console::info("Deleting deployments for function " . $functionId); - $storageFunctions = new Local(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); + $storageFunctions = $this->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); $deploymentIds = []; $this->deleteByGroup('deployments', [ Query::equal('resourceId', [$functionId]) @@ -442,7 +442,7 @@ class DeletesV1 extends Worker * Delete builds */ Console::info("Deleting builds for function " . $functionId); - $storageBuilds = new Local(APP_STORAGE_BUILDS . '/app-' . $projectId); + $storageBuilds = $this->getDevice(APP_STORAGE_BUILDS . '/app-' . $projectId); foreach ($deploymentIds as $deploymentId) { $this->deleteByGroup('builds', [ Query::equal('deploymentId', [$deploymentId]) @@ -491,7 +491,7 @@ class DeletesV1 extends Worker * Delete deployment files */ Console::info("Deleting deployment files for deployment " . $deploymentId); - $storageFunctions = new Local(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); + $storageFunctions = $this->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); if ($storageFunctions->delete($document->getAttribute('path', ''), true)) { Console::success('Deleted deployment files: ' . $document->getAttribute('path', '')); } else { @@ -502,7 +502,7 @@ class DeletesV1 extends Worker * Delete builds */ Console::info("Deleting builds for deployment " . $deploymentId); - $storageBuilds = new Local(APP_STORAGE_BUILDS . '/app-' . $projectId); + $storageBuilds = $this->getDevice(APP_STORAGE_BUILDS . '/app-' . $projectId); $this->deleteByGroup('builds', [ Query::equal('deploymentId', [$deploymentId]) ], $dbForProject, function (Document $document) use ($storageBuilds) { diff --git a/composer.lock b/composer.lock index c0320c77d..c66b7f2dc 100644 --- a/composer.lock +++ b/composer.lock @@ -115,15 +115,15 @@ }, { "name": "appwrite/php-runtimes", - "version": "0.11.0", + "version": "0.11.1", "source": { "type": "git", "url": "https://github.com/appwrite/runtimes.git", - "reference": "547fc026e11c0946846a8ac690898f5bf53be101" + "reference": "9d74a477ba3333cbcfac565c46fcf19606b7b603" }, "require": { "php": ">=8.0", - "utopia-php/system": "0.4.*" + "utopia-php/system": "0.6.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -154,7 +154,7 @@ "php", "runtimes" ], - "time": "2022-08-15T14:03:36+00:00" + "time": "2022-11-07T16:45:52+00:00" }, { "name": "chillerlan/php-qrcode", @@ -300,16 +300,16 @@ }, { "name": "colinmollenhour/credis", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/colinmollenhour/credis.git", - "reference": "85df015088e00daf8ce395189de22c8eb45c8d49" + "reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/85df015088e00daf8ce395189de22c8eb45c8d49", - "reference": "85df015088e00daf8ce395189de22c8eb45c8d49", + "url": "https://api.github.com/repos/colinmollenhour/credis/zipball/dccc8a46586475075fbb012d8bd523b8a938c2dc", + "reference": "dccc8a46586475075fbb012d8bd523b8a938c2dc", "shasum": "" }, "require": { @@ -341,9 +341,9 @@ "homepage": "https://github.com/colinmollenhour/credis", "support": { "issues": "https://github.com/colinmollenhour/credis/issues", - "source": "https://github.com/colinmollenhour/credis/tree/v1.13.1" + "source": "https://github.com/colinmollenhour/credis/tree/v1.14.0" }, - "time": "2022-06-20T22:56:59+00:00" + "time": "2022-11-09T01:18:39+00:00" }, { "name": "dragonmantank/cron-expression", @@ -803,6 +803,72 @@ }, "time": "2020-12-26T17:45:17+00:00" }, + { + "name": "laravel/pint", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/pint.git", + "reference": "1d276e4c803397a26cc337df908f55c2a4e90d86" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/pint/zipball/1d276e4c803397a26cc337df908f55c2a4e90d86", + "reference": "1d276e4c803397a26cc337df908f55c2a4e90d86", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-tokenizer": "*", + "ext-xml": "*", + "php": "^8.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.11.0", + "illuminate/view": "^9.27", + "laravel-zero/framework": "^9.1.3", + "mockery/mockery": "^1.5.0", + "nunomaduro/larastan": "^2.2", + "nunomaduro/termwind": "^1.14.0", + "pestphp/pest": "^1.22.1" + }, + "bin": [ + "builds/pint" + ], + "type": "project", + "autoload": { + "psr-4": { + "App\\": "app/", + "Database\\Seeders\\": "database/seeders/", + "Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nuno Maduro", + "email": "enunomaduro@gmail.com" + } + ], + "description": "An opinionated code formatter for PHP.", + "homepage": "https://laravel.com", + "keywords": [ + "format", + "formatter", + "lint", + "linter", + "php" + ], + "support": { + "issues": "https://github.com/laravel/pint/issues", + "source": "https://github.com/laravel/pint" + }, + "time": "2022-09-13T15:07:15+00:00" + }, { "name": "matomo/device-detector", "version": "6.0.0", @@ -2368,23 +2434,25 @@ }, { "name": "utopia-php/system", - "version": "0.4.0", + "version": "0.6.0", "source": { "type": "git", "url": "https://github.com/utopia-php/system.git", - "reference": "67c92c66ce8f0cc925a00bca89f7a188bf9183c0" + "reference": "289c4327713deadc9c748b5317d248133a02f245" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/system/zipball/67c92c66ce8f0cc925a00bca89f7a188bf9183c0", - "reference": "67c92c66ce8f0cc925a00bca89f7a188bf9183c0", + "url": "https://api.github.com/repos/utopia-php/system/zipball/289c4327713deadc9c748b5317d248133a02f245", + "reference": "289c4327713deadc9c748b5317d248133a02f245", "shasum": "" }, "require": { + "laravel/pint": "1.2.*", "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "^9.3", + "squizlabs/php_codesniffer": "^3.6", "vimeo/psalm": "4.0.1" }, "type": "library", @@ -2417,9 +2485,9 @@ ], "support": { "issues": "https://github.com/utopia-php/system/issues", - "source": "https://github.com/utopia-php/system/tree/0.4.0" + "source": "https://github.com/utopia-php/system/tree/0.6.0" }, - "time": "2021-02-04T14:14:49+00:00" + "time": "2022-11-07T13:51:59+00:00" }, { "name": "utopia-php/websocket", @@ -4725,16 +4793,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -4749,7 +4817,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4787,7 +4855,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -4803,20 +4871,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -4831,7 +4899,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -4870,7 +4938,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -4886,7 +4954,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "textalk/websocket", @@ -5064,14 +5132,7 @@ "time": "2022-09-28T08:42:51+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "0.28.0.0", - "alias": "0.26.99", - "alias_normalized": "0.26.99.0" - } - ], + "aliases": [], "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, @@ -5097,5 +5158,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } From f2f56aa310b7b71cf311b77490b45e978d3e0085 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Thu, 10 Nov 2022 13:51:32 +0000 Subject: [PATCH 2/4] chore: update changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 2c649ab5f..a6fea96d6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,7 @@ ## Bugs - Fix license detection for Flutter and Dart SDKs [#4435](https://github.com/appwrite/appwrite/pull/4435) - Fix missing realtime event for create function deployment [#4574](https://github.com/appwrite/appwrite/pull/4574) +- Fix Deletes worker using incorrect device to delete files from [#4662](https://github.com/appwrite/appwrite/pull/4662) # Version 1.0.3 ## Bugs From 72a37516d39124dec66b6078877d1ae65337171e Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 11 Nov 2022 13:54:05 +0000 Subject: [PATCH 3/4] feat: address review comments: --- app/workers/deletes.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index c4512adf2..fad2fdeac 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -259,8 +259,8 @@ class DeletesV1 extends Worker $this->getProjectDB($projectId)->delete($projectId); // Delete all storage directories - $uploads = $this->getDevice(APP_STORAGE_UPLOADS . '/app-' . $document->getId()); - $cache = $this->getDevice(APP_STORAGE_CACHE . '/app-' . $document->getId()); + $uploads = $this->getFilesDevice($document->getId()); + $cache = new Local(APP_STORAGE_CACHE . '/app-' . $document->getId()); $uploads->delete($uploads->getRoot(), true); $cache->delete($cache->getRoot(), true); @@ -425,7 +425,7 @@ class DeletesV1 extends Worker * Delete Deployments */ Console::info("Deleting deployments for function " . $functionId); - $storageFunctions = $this->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); + $storageFunctions = $this->getFunctionsDevice($projectId); $deploymentIds = []; $this->deleteByGroup('deployments', [ Query::equal('resourceId', [$functionId]) @@ -442,7 +442,7 @@ class DeletesV1 extends Worker * Delete builds */ Console::info("Deleting builds for function " . $functionId); - $storageBuilds = $this->getDevice(APP_STORAGE_BUILDS . '/app-' . $projectId); + $storageBuilds = $this->getBuildsDevice($projectId); foreach ($deploymentIds as $deploymentId) { $this->deleteByGroup('builds', [ Query::equal('deploymentId', [$deploymentId]) @@ -491,7 +491,7 @@ class DeletesV1 extends Worker * Delete deployment files */ Console::info("Deleting deployment files for deployment " . $deploymentId); - $storageFunctions = $this->getDevice(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); + $storageFunctions = $this->getFunctionsDevice($projectId); if ($storageFunctions->delete($document->getAttribute('path', ''), true)) { Console::success('Deleted deployment files: ' . $document->getAttribute('path', '')); } else { @@ -502,7 +502,7 @@ class DeletesV1 extends Worker * Delete builds */ Console::info("Deleting builds for deployment " . $deploymentId); - $storageBuilds = $this->getDevice(APP_STORAGE_BUILDS . '/app-' . $projectId); + $storageBuilds = $this->getBuildsDevice($projectId); $this->deleteByGroup('builds', [ Query::equal('deploymentId', [$deploymentId]) ], $dbForProject, function (Document $document) use ($storageBuilds) { @@ -671,7 +671,7 @@ class DeletesV1 extends Worker $dbForProject = $this->getProjectDB($projectId); $dbForProject->deleteCollection('bucket_' . $document->getInternalId()); - $device = $this->getDevice(APP_STORAGE_UPLOADS . '/app-' . $projectId); + $device = $this->getFilesDevice($projectId); $device->deletePath($document->getId()); } From 17a36dbce3a58c064f43deef2fd199364600e6b1 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 16 Nov 2022 11:15:24 +0000 Subject: [PATCH 4/4] feat: update changelog --- CHANGES.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6b467c85a..2e24c7417 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# Version TBD + +## Bugs +- Fix Deletes worker using incorrect device for file deletion [#4662](https://github.com/appwrite/appwrite/pull/4662) + # Version 1.1.0 ## Features - Added support for the new Appwrite Console [#4655](https://github.com/appwrite/appwrite/pull/4655) @@ -5,13 +10,6 @@ ## Bugs - Fix license detection for Flutter and Dart SDKs [#4435](https://github.com/appwrite/appwrite/pull/4435) -- Fix missing realtime event for create function deployment [#4574](https://github.com/appwrite/appwrite/pull/4574) -- Fix Deletes worker using incorrect device to delete files from [#4662](https://github.com/appwrite/appwrite/pull/4662) -- Fix missing status, buildStderr and buildStderr from get deployment response [#4611](https://github.com/appwrite/appwrite/pull/4611) - -# Version 1.0.4 - -- Fix project pagination in DB usage collector [#4517](https://github.com/appwrite/appwrite/pull/4517) - Fix missing `status`, `buildStderr` and `buildStderr` from get deployment response [#4611](https://github.com/appwrite/appwrite/pull/4611) - Fix project pagination in DB usage aggregation [#4517](https://github.com/appwrite/appwrite/pull/4517) - Fix missing file permissions due to cache [#4661](https://github.com/appwrite/appwrite/pull/4661)