DEV: Do not abort direct S3 uploads if upload_debug_mode enabled (#14141)

DEV: Do not abort direct S3 uploads if upload_debug_mode enabled (#14141)

See the previous commit d66b258b0e9a635a67007b1d95d3d50475f662cf as well.

If enable_upload_debug_mode is true, we do not want to abort the direct S3 upload, because that will delete the file on S3 and prevent further inspection of any errors that have come up.

diff --git a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
index 97cd755..824a9a6 100644
--- a/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
+++ b/app/assets/javascripts/discourse/app/mixins/composer-upload-uppy.js
@@ -239,6 +239,8 @@ export default Mixin.create({
     this._inProgressUploads--;
     this._resetUpload(file, { removePlaceholder: true });
 
+    file.meta.error = error;
+
     if (!this.userCancelled) {
       displayErrorForUpload(response || error, this.siteSettings, file.name);
       this.appEvents.trigger("composer:upload-error", file);
@@ -433,6 +435,13 @@ export default Mixin.create({
           return;
         }
 
+        // this gives us a chance to inspect the upload stub before
+        // it is deleted from external storage by aborting the multipart
+        // upload; see also ExternalUploadManager
+        if (file.meta.error && self.siteSettings.enable_upload_debug_mode) {
+          return;
+        }
+
         return ajax("/uploads/abort-multipart.json", {
           type: "POST",
           data: {
diff --git a/config/site_settings.yml b/config/site_settings.yml
index b9f5950..f6d7582 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -283,6 +283,7 @@ basic:
   enable_upload_debug_mode:
     default: false
     hidden: true
+    client: true
   default_theme_id:
     default: -1
     hidden: true

GitHub sha: 58e9fffe4cd0156284257c64306a6af0133367e0