diff --git a/@xen-orchestra/fs/src/abstract.js b/@xen-orchestra/fs/src/abstract.js index 65058e5e0..7a3cb6778 100644 --- a/@xen-orchestra/fs/src/abstract.js +++ b/@xen-orchestra/fs/src/abstract.js @@ -624,14 +624,18 @@ export default class RemoteHandlerAbstract { const files = await this._list(dir) await asyncEach(files, file => - this._unlink(`${dir}/${file}`).catch(error => { - // Unlink dir behavior is not consistent across platforms - // https://github.com/nodejs/node-v0.x-archive/issues/5791 - if (error.code === 'EISDIR' || error.code === 'EPERM') { - return this._rmtree(`${dir}/${file}`) - } - throw error - }) + this._unlink(`${dir}/${file}`).catch( + error => { + // Unlink dir behavior is not consistent across platforms + // https://github.com/nodejs/node-v0.x-archive/issues/5791 + if (error.code === 'EISDIR' || error.code === 'EPERM') { + return this._rmtree(`${dir}/${file}`) + } + throw error + }, + // real unlink concurrency will be 2**max directory depth + { concurrency: 2 } + ) ) return this._rmtree(dir) }