Skip to content

Commit

Permalink
synchronized updateCache
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-f committed Sep 9, 2022
1 parent eca6244 commit f5b4889
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions @xen-orchestra/backups/RemoteAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -612,7 +614,7 @@ class RemoteAdapter {
})

// will not throw
this.#updateCache(this.#getVmBackupsCache(vmUuid), backups => {
this._updateCache(this.#getVmBackupsCache(vmUuid), backups => {
backups[path] = {
...metadata,

Expand Down

0 comments on commit f5b4889

Please sign in to comment.