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
This commit is contained in:
Jonas 2024-06-04 15:48:34 +02:00
parent 3663c4a719
commit f3cd03b141
No known key found for this signature in database
GPG key ID: 5262E7FF491049FE

View file

@ -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,