From f5b48897b26368841b0d84415d4e19ede5dbb457 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 9 Sep 2022 10:33:03 +0200 Subject: [PATCH] synchronized updateCache --- @xen-orchestra/backups/RemoteAdapter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/@xen-orchestra/backups/RemoteAdapter.js b/@xen-orchestra/backups/RemoteAdapter.js index f5539f71696..1b27e853f45 100644 --- a/@xen-orchestra/backups/RemoteAdapter.js +++ b/@xen-orchestra/backups/RemoteAdapter.js @@ -233,7 +233,7 @@ class RemoteAdapter { ) )) { // detached async action, will not reject - this.#updateCache(dir + '/cache.json.gz', backups => { + this._updateCache(dir + '/cache.json.gz', backups => { for (const filename of filenames) { delete backups[filename] } @@ -490,7 +490,9 @@ class RemoteAdapter { } } - async #updateCache(path, fn) { + _updateCache = synchronized.withKey()(this._updateCache) + // eslint-disable-next-line no-dupe-class-members + async _updateCache(path, fn) { const cache = await this.#readCache(path) if (cache !== undefined) { fn(cache) @@ -612,7 +614,7 @@ class RemoteAdapter { }) // will not throw - this.#updateCache(this.#getVmBackupsCache(vmUuid), backups => { + this._updateCache(this.#getVmBackupsCache(vmUuid), backups => { backups[path] = { ...metadata,