DEV: Do not delete failed uploads from S3 in debug mode (#14143)

DEV: Do not delete failed uploads from S3 in debug mode (#14143)

See also 58e9fffe4cd0156284257c64306a6af0133367e0

diff --git a/app/services/external_upload_manager.rb b/app/services/external_upload_manager.rb
index dceebe0..d08cee6 100644
--- a/app/services/external_upload_manager.rb
+++ b/app/services/external_upload_manager.rb
@@ -84,12 +84,11 @@ class ExternalUploadManager
       external_upload_stub.created_by_id
     )
   rescue
-    # We don't need to do anything special to abort multipart uploads here,
-    # because at this point (calling promote_to_upload!), the multipart
-    # upload would already be complete.
-    Discourse.store.delete_file(external_upload_stub.key)
-
     if !SiteSetting.enable_upload_debug_mode
+      # We don't need to do anything special to abort multipart uploads here,
+      # because at this point (calling promote_to_upload!), the multipart
+      # upload would already be complete.
+      Discourse.store.delete_file(external_upload_stub.key)
       external_upload_stub.destroy!
     else
       external_upload_stub.update(status: ExternalUploadStub.statuses[:failed])

GitHub sha: a7ec1a86b5108f47ed4cd801048d243ed1c60f7b

This commit appears in #14143 which was approved by tgxworld. It was merged by martin.