Describe the Bug
When creating multiple files simultaneously using beaker.hyperdrive.writeFile, files after the first will fail with an uncaught error.
index.html:1 Uncaught (in promise) Error: Uncaught Error: PathAlreadyExists: Path...already exists.
To Reproduce
Expected Behavior
Considering the purpose of the function, either the API should fail every time when a directory does not exist or, better yet, the API should eat the error and continue.
Screenshots
Presumed unecessary. If needed can supply.
Environment
Additional Context
Presumed unecessary. If needed can supply.
Can you share what the code looks like for this?
writeFile() creates parent directories as-needed. I suspect what's happening is that concurrent calls to writeFile() are attempting to create those parent dirs at the same time, thus the issue. Go ahead and share a snippet so I can be sure I'm right about this.
Thanks for filing, does look like a legit bug.
Here's the inelegant code:
acceptedFiles.forEach(file => {
beaker.hyperdrive.readFile('hyper://' + address + locationFromFile(file), 'json').then(result => {
beaker.hyperdrive.writeFile('/cache/' + address + '/' + file + '.json', result, 'json');
if(file = 'follows' && distance > 0) {
result.forEach(follow => {
if(follow.address != undefined && !crawled.includes(follow.address)) crawl(distance - 1, follow.address, false);
});
}
});
});
(Pertinent bit:)
acceptedFiles.forEach(file => {
beaker.hyperdrive.readFile('hyper://' + address + locationFromFile(file), 'json').then(result => {
beaker.hyperdrive.writeFile('/cache/' + address + '/' + file + '.json', result, 'json');
});
Most helpful comment
Can you share what the code looks like for this?
writeFile()creates parent directories as-needed. I suspect what's happening is that concurrent calls towriteFile()are attempting to create those parent dirs at the same time, thus the issue. Go ahead and share a snippet so I can be sure I'm right about this.Thanks for filing, does look like a legit bug.