-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
The problem
Files that you know only the name of may be open.
(async () => {
const randomName = Math.random().toString().substr(2);
try {
// Create a file, but keep no reference to it.
await storageFoundation.open(randomName);
console.log('Created', randomName);
// Delete all files.
storageFoundation.getAll().then((names) => names.forEach(async (name) => {
console.log('Deleting', name);
// This fails, since the just created file is open.
await storageFoundation.delete(name);
// Throws a `DOMException: File is open` error.
// At the same time there is no way to close the file, since all I have
// at this stage is the file's `name`, and I can't call `NativeIOFile.close()`
// without a file reference.
}));
} catch (err) {
console.error(err.name, err.message);
}
})();Possible solution
Make it possible to get a reference to a file and make its state queryable like so:
const file = await storageFoundation.getFileReference(name);
if (await file.isOpen()) {
await file.close();
}
// Deleting would now succeed.Metadata
Metadata
Assignees
Labels
No labels