This is one of those annoying bugs where it works in some cases, on some machines.
The main problem is, when the permission error is thrown, it does not explain why Chrome has no permission to move the file.
Full error message:
NotAllowedError: The request is not allowed by the user agent or the platform in the current context.
What’s the context? How many contexts are there?
Code:
const backupFileHandle = await dirHandle.getFileHandle("tmpfile", {create: true});
const writable = await backupFileHandle.createWritable();
let fileContent = "";
fileContent = `All good`;
await writable.write(fileContent, {type: 'text/plain'});
await writable.close();
await backupFileHandle.move("realfilename.real"); // This line works sometimes
Grateful for any hints.