I am saving a FileSystemDirectoryHandle to IndexedDB, so that the web application can reuse it the next time it is started. This usually works fine. But when the directory has been removed from disk in the meantime, and the app still tries to work with it (for example by trying to obtain a file handle inside the directory via directoryHandle.getFileHandle()
), an error is thrown, unsurprisingly: NotFoundError: A requested file or directory could not be found at the time an operation was processed.
How to check if the directory still exists before doing anything else with it? In Node.js, there are functions for checking if a directory exists like fs.access
and fs.existsSync
. But I do not find anything like that with the File System Access API.