-
Hi, I'm working with ZenFS and have encountered an issue while trying to initialize the file system. Specifically, I’m receiving the following error:
Based on the error message, it seems the "index" passed into the resolveMountConfig function might not be in the expected format. I’m using the following structure for the indexData (based on the IndexData interface from the documentation): interface IndexData {
entries: Record<string, StatsLike<number>>;
version: number;
} Here’s an example of the indexData I’m passing: {
"entries": {
".index": { "mode": 16877, "size": 4096, "mtime": 1736270682359 },
"files": { "mode": 16877, "size": 4096, "mtime": 1736265140681 },
"icons": { "mode": 16877, "size": 4096, "mtime": 1736167012567 }
},
"version": 4,
"size": 18631
} I’ve confirmed that the indexData is being properly parsed and passed as an object to resolveMountConfig. However, I’m still encountering the error. I’d appreciate your guidance on whether this JSON format is correct and why I might be receiving this EINVAL error. Is the expected index format a string or an object in this context? If it should be an object, is there something else I might be missing in how the data is passed? Looking forward to your response! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @ayoubbif, thanks for reaching out! What does your configuration look like? Also, for the JSON data, you can use the |
Beta Was this translation helpful? Give feedback.
-
Hi @james-pre, I use the following to initialize the file system in my application: import { configure, fs, resolveMountConfig, Overlay, Fetch } from "@zenfs/core";
import { IndexedDB } from "@zenfs/dom";
useEffect(() => {
const initializeFileSystem = async () => {
try {
// Fetch the index file and parse it into an object
const indexResponse = await fetch(".index/fs.zen.json");
const indexData = await indexResponse.json();
// Resolve mount configurations
const readable = await resolveMountConfig({
backend: Fetch,
index: indexData,
});
const writable = await resolveMountConfig({
backend: IndexedDB,
storeName: "zenfs-cache",
});
// Configure the file system
await configure({
mounts: {
"/": {
backend: Overlay,
readable,
writable,
},
},
});
setFsState({ fs, isReady: true });
} catch (error) {
console.error("FileSystem initialization error:", error);
}
};
initializeFileSystem();
}, []); Thank you for recommending |
Beta Was this translation helpful? Give feedback.
This is a bug with ZenFS when a backend allows multiple types for a configuration option. A patch will be released soon.