From f3cd03b141f7ee27ba0e71b9cdcaad0bb3ef9bf9 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 4 Jun 2024 15:48:34 +0200 Subject: [PATCH] fix(dialogs): Make sure conflict dialog is loaded before adding conflicts Fixes a possible race condition where conflicts are added and the dialog loading finishes only afterwards. The race condition sometimes led to missing files in the conflict dialog when uploading several existing files at once. Fixes: #45661 --- core/src/OC/dialogs.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core/src/OC/dialogs.js b/core/src/OC/dialogs.js index ad501ee0628..ef62b7ad6a8 100644 --- a/core/src/OC/dialogs.js +++ b/core/src/OC/dialogs.js @@ -918,27 +918,28 @@ const Dialogs = { var dialogName = 'oc-dialog-fileexists-content' var dialogId = '#' + dialogName if (this._fileexistsshown) { - // add conflict + this._fileexistsshown.then(() => { + // add conflict - var $conflicts = $(dialogId + ' .conflicts') - addConflict($conflicts, original, replacement) + var $conflicts = $(dialogId + ' .conflicts') + addConflict($conflicts, original, replacement) - var count = $(dialogId + ' .conflict').length - var title = n('core', - '{count} file conflict', - '{count} file conflicts', - count, - { count: count } - ) - $(dialogId).parent().children('.oc-dialog-title').text(title) + var count = $(dialogId + ' .conflict').length + var title = n('core', + '{count} file conflict', + '{count} file conflicts', + count, + { count: count } + ) + $(dialogId).parent().children('.oc-dialog-title').text(title) - // recalculate dimensions - $(window).trigger('resize') - dialogDeferred.resolve() + // recalculate dimensions + $(window).trigger('resize') + dialogDeferred.resolve() + }) } else { // create dialog - this._fileexistsshown = true - $.when(this._getFileExistsTemplate()).then(function($tmpl) { + this._fileexistsshown = $.when(this._getFileExistsTemplate()).then(function($tmpl) { var title = t('core', 'One file conflict') var $dlg = $tmpl.octemplate({ dialog_name: dialogName,