Skip to content

Commit d034d12

Browse files
committed
Fix IDBFS not auto-persisting on directory creation
mkdir has never been a node operation as FS.mkdir uses mknod instead. Add a check for file mode and queue a persist operation immediately if the node is a directory and won't ever be opened/closed like a file.
1 parent 5c9c390 commit d034d12

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/lib/libidbfs.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,14 @@ addToLibrary({
8585
if (n.memfs_stream_ops.close) return n.memfs_stream_ops.close(stream);
8686
};
8787

88+
// Persist IndexedDB right away if the node we just created is a directory
89+
if (FS.isDir(mode)) {
90+
IDBFS.queuePersist(mnt.mount);
91+
}
92+
8893
return node;
8994
};
9095
// Also kick off persisting the filesystem on other operations that modify the filesystem.
91-
mnt.node_ops.mkdir = (...args) => (IDBFS.queuePersist(mnt.mount), memfs_node_ops.mkdir(...args));
9296
mnt.node_ops.rmdir = (...args) => (IDBFS.queuePersist(mnt.mount), memfs_node_ops.rmdir(...args));
9397
mnt.node_ops.symlink = (...args) => (IDBFS.queuePersist(mnt.mount), memfs_node_ops.symlink(...args));
9498
mnt.node_ops.unlink = (...args) => (IDBFS.queuePersist(mnt.mount), memfs_node_ops.unlink(...args));

0 commit comments

Comments
 (0)