From f02707627f5511e5d807ddcc85999fa29e85e3d8 Mon Sep 17 00:00:00 2001 From: Khushboo Verma Date: Mon, 14 Apr 2025 12:16:50 +0000 Subject: [PATCH] Refactor --- app/controllers/api/functions.php | 7 ++++++- src/Appwrite/Platform/Workers/Builds.php | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 0bb7523181..5849de9dd9 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -1312,7 +1312,12 @@ App::post('/v1/functions/:functionId/deployments') throw new Exception(Exception::STORAGE_FILE_EMPTY, 'No file sent'); } - $functionFileSize = isset($plan['functionSize']) ? $plan['functionSize'] * 1000 * 1000 : (System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT') ?: 30000000); + $functionFileSize = (System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT') ?: 30000000); + + if (isset($plan['functionSize'])) { + $functionFileSize = $plan['functionSize'] * 1000 * 1000; + } + $fileExt = new FileExt([FileExt::TYPE_GZIP]); $fileSizeValidator = new FileSize($functionFileSize); $upload = new Upload(); diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 5be7a0e526..d838152892 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -405,9 +405,11 @@ class Builds extends Action $directorySize = $localDevice->getDirectorySize($tmpDirectory); - $functionsSizeLimit = empty($plan['functionSize']) - ? (int) System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT', 30000000) - : (int) $plan['functionSize'] * 1000 * 1000; + $functionsSizeLimit = (int) (System::getEnv('_APP_FUNCTIONS_SIZE_LIMIT') ?: 30000000); + + if (!empty($plan['functionSize'])) { + $functionsSizeLimit = (int) $plan['functionSize'] * 1000 * 1000; + } if ($directorySize > $functionsSizeLimit) { throw new \Exception('Repository directory size should be less than ' . number_format($functionsSizeLimit / 1048576, 2) . ' MBs.');