From 3452541b6ddae9500315402b3bc571f4eceebb8a Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 30 Dec 2021 17:08:46 +0545 Subject: [PATCH] modify console ui for incomplete uploads and handle proper deletion of incomplete uploads --- app/controllers/api/storage.php | 9 ++++++++- app/views/console/storage/bucket.phtml | 11 +++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 7907cec66d..fcfd29dc6e 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -1643,7 +1643,14 @@ App::delete('/v1/storage/buckets/:bucketId/files/:fileId') $device = Storage::getDevice('files'); - if ($device->delete($file->getAttribute('path', ''))) { + $deviceDeleted = false; + if($file->getAttribute('chunksTotal') !== $file->getAttribute('chunksUploaded')) { + $deviceDeleted = $device->abort($file->getAttribute('path')); + } else { + $deviceDeleted = $device->delete($file->getAttribute('path')); + } + + if ($deviceDeleted) { if ($bucket->getAttribute('permission') === 'bucket') { $deleted = Authorization::skip(function() use ($dbForExternal, $fileId, $bucketId) { return $dbForExternal->deleteDocument('bucket_' . $bucketId, $fileId); diff --git a/app/views/console/storage/bucket.phtml b/app/views/console/storage/bucket.phtml index 8f31b24d9d..ce87a5de96 100644 --- a/app/views/console/storage/bucket.phtml +++ b/app/views/console/storage/bucket.phtml @@ -158,7 +158,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0); -
+
File Preview
@@ -188,7 +188,7 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0);
-   +  
@@ -196,8 +196,11 @@ $fileLimitHuman = $this->getParam('fileLimitHuman', 0); - - +
+ + +
+ incomplete