Skip to content

Commit

Permalink
Fix rare race condition when moving/copying/deleting files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsage committed Nov 16, 2022
1 parent c4f3272 commit bfcb74c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions modAssist_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,12 +566,17 @@ function createVersionWindow() {
}

function loadingWindow_open(l10n) {
log.log.debug(`Load Window: ${l10n}`, 'load-window')
const winTitle = myTranslator.syncStringLookup(`loading_${l10n}_title`)
const winSubTitle = myTranslator.syncStringLookup(`loading_${l10n}_subtitle`)
if ( windows.load ) {
windows.load.show()
windows.load.focus()
windows.load.webContents.send('formMain_loadingTitles', winTitle, winSubTitle)
setTimeout(() => {
windows.load.show()
windows.load.focus()
}, 250)
return
}
}
Expand All @@ -586,6 +591,7 @@ function loadingWindow_current(amount = 1, reset = false) {
windows.load.webContents.send('fromMain_loadingCurrent', countMods)
}
function loadingWindow_hide(time = 1250) {
log.log.debug('Load Window: hide!', 'load-window')
setTimeout(() => { windows.load.hide() }, time)
}
function loadingWindow_noCount() {
Expand Down Expand Up @@ -1252,7 +1258,24 @@ function parseSettings({disable = null, newFolder = null, userName = null, serve
}
}

let fileWait = null
function fileOperation(type, fileMap, srcWindow = 'confirm') {
windows[srcWindow].close()

loadingWindow_open('files', 'main')
loadingWindow_total(fileMap.length, true)
loadingWindow_current(0, true)

fileWait = setInterval(() => {
if ( windows.load.isVisible() ) {
clearInterval(fileWait)
fileOperation_post(type, fileMap)
}
}, 250)
}


function fileOperation_post(type, fileMap) {
const fullPathMap = []

fileMap.forEach((file) => {
Expand All @@ -1263,15 +1286,8 @@ function fileOperation(type, fileMap, srcWindow = 'confirm') {
])
})

windows[srcWindow].close()
windows.main.focus()

foldersDirty = true

loadingWindow_open('files', 'main')
loadingWindow_total(fullPathMap.length, true)
loadingWindow_current(0, true)

fullPathMap.forEach((file) => {
try {
switch ( type ) {
Expand Down
2 changes: 1 addition & 1 deletion renderer/renderJS/select_lib_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
const select_lib = {
last_select_mod : null,
last_select_table : null,
clear_range : () => { select_lib.last_select_mod = null; select_lib.last_select_table = null },
clear_range : () => { select_lib.last_select_mod = null; select_lib.last_select_table = null; select_lib.update_color() },
click_row : (modID) => {
const isShift = window.event.shiftKey
const thisTable = document.getElementById(modID).closest('table').closest('tr').id
Expand Down

0 comments on commit bfcb74c

Please sign in to comment.