attempt fix for double loading of accounts at start

Massimo Melina committed Mar 6, 2022 at 23:57 UTC d0c066d9d9aaa910cc37c5372cc6a9974b61a386
1 file changed +4 -2
server/src/watchLoad.ts
+4 -2
@@ -34,12 +34,15 @@ export function watchLoad(path:string, parser:(data:any)=>void|Promise<void>, {
34 }
35
36 function init() {
37 + let triggered = false
38 try {
39 watcher = watch(path, ()=> {
40 + triggered = true
41 if (!saving)
42 debounced().then()
43 })
42 - debounced().then() // if file is not accessible watch will throw, and we won't get here
44 + if (!triggered)
45 + debounced().then() // if file is not accessible watch will throw, and we won't get here
46 }
47 catch {
48 retry = setTimeout(init, 1000) // manual watching until watch is successful
@@ -65,4 +68,3 @@ export function watchLoad(path:string, parser:(data:any)=>void|Promise<void>, {
68 }
69 }
70 }
68 -