Skip to content

Commit d8dab61

Browse files
committed
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
1 parent 162073f commit d8dab61

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

core/src/OC/dialogs.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -918,27 +918,28 @@ const Dialogs = {
918918
var dialogName = 'oc-dialog-fileexists-content'
919919
var dialogId = '#' + dialogName
920920
if (this._fileexistsshown) {
921-
// add conflict
922-
923-
var $conflicts = $(dialogId + ' .conflicts')
924-
addConflict($conflicts, original, replacement)
925-
926-
var count = $(dialogId + ' .conflict').length
927-
var title = n('core',
928-
'{count} file conflict',
929-
'{count} file conflicts',
930-
count,
931-
{ count: count }
932-
)
933-
$(dialogId).parent().children('.oc-dialog-title').text(title)
934-
935-
// recalculate dimensions
936-
$(window).trigger('resize')
937-
dialogDeferred.resolve()
921+
this._fileexistsshown.then(() => {
922+
// add conflict
923+
924+
var $conflicts = $(dialogId + ' .conflicts')
925+
addConflict($conflicts, original, replacement)
926+
927+
var count = $(dialogId + ' .conflict').length
928+
var title = n('core',
929+
'{count} file conflict',
930+
'{count} file conflicts',
931+
count,
932+
{ count: count }
933+
)
934+
$(dialogId).parent().children('.oc-dialog-title').text(title)
935+
936+
// recalculate dimensions
937+
$(window).trigger('resize')
938+
dialogDeferred.resolve()
939+
})
938940
} else {
939941
// create dialog
940-
this._fileexistsshown = true
941-
$.when(this._getFileExistsTemplate()).then(function($tmpl) {
942+
this._fileexistsshown = $.when(this._getFileExistsTemplate()).then(function($tmpl) {
942943
var title = t('core', 'One file conflict')
943944
var $dlg = $tmpl.octemplate({
944945
dialog_name: dialogName,

0 commit comments

Comments
 (0)