From 7508e9f631669a7697caf1e83c560e17c19c0c56 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 25 Nov 2021 10:44:38 +0545 Subject: [PATCH] update deletes to account for different storage device --- app/workers/deletes.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/workers/deletes.php b/app/workers/deletes.php index c7ed436507..b7799b3a30 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -1,11 +1,15 @@ getExternalDB($projectId)); + $device = new Local(APP_STORAGE_UPLOADS.'/app-'.$projectId); + + switch (App::getEnv('_APP_STORAGE_DEVICE', Storage::DEVICE_LOCAL)) { + case Storage::DEVICE_S3: + $s3AccessKey = App::getEnv('_APP_STORAGE_DEVICE_S3_ACCESS_KEY', ''); + $s3SecretKey = App::getEnv('_APP_STORAGE_DEVICE_S3_SECRET', ''); + $s3Region = App::getEnv('_APP_STORAGE_DEVICE_S3_REGION', ''); + $s3Bucket = App::getEnv('_APP_STORAGE_DEVICE_S3_BUCKET', ''); + $s3Acl = 'private'; + $device = new S3(APP_STORAGE_UPLOADS . '/app-' . $projectId, $s3AccessKey, $s3SecretKey, $s3Bucket, $s3Region, $s3Acl); + break; + case Storage::DEVICE_DO_SPACES: + $doSpacesAccessKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_ACCESS_KEY', ''); + $doSpacesSecretKey = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_SECRET', ''); + $doSpacesRegion = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_REGION', ''); + $doSpacesBucket = App::getEnv('_APP_STORAGE_DEVICE_DO_SPACES_BUCKET', ''); + $doSpacesAcl = 'private'; + $device = new DoSpaces(APP_STORAGE_UPLOADS . '/app-' . $projectId, $doSpacesAccessKey, $doSpacesSecretKey, $doSpacesBucket, $doSpacesRegion, $doSpacesAcl); + break; + } + $device = new Local(APP_STORAGE_UPLOADS.'/app-'.$projectId); $device->deletePath($device->getRoot() . DIRECTORY_SEPARATOR . $bucketId); }