Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fetch: How to update index? #248

Unanswered
kachurun asked this question in Q&A
Discussion options

Hi! Thank you for an amazing tool! But it definitely has a lack of documentation, and now I can't understand how I can reload the index with FetchFS in case the files have changed on my server.

I have code like this:

export const mountBrowserFS = async(mountDir: string, baseUrl: string) => {
 const fetchFS = await resolveMountConfig({
 backend: Fetch,
 index: `${ baseUrl }/index.json`,
 baseUrl,
 disableAsyncCache: true,
 remoteWrite: true,
 });
 mount(mountDir, fetchFS);
 return true;
};

So I have an idea to unmount before mounting, but it feels a little bit dirty.

You must be logged in to vote

Replies: 3 comments

Comment options

Hey @kachurun, thanks for reaching out.

There isn't currently a method for reloading the index, though I would be willing to add it.

As for normal, I recommend you use the configure/configureSingle functions.

In case you weren't aware, there is extensive documentation available on zenfs.dev.

You must be logged in to vote
0 replies
Comment options

@james-pre
Thank you for fast answer!

I did this:

import '@common_src/polyfills/buffer';
import { Fetch, mount, resolveMountConfig, umount } from '@zenfs/core';
const mounted = new Map<string, boolean>();
export const unmountBrowserFS = (mountDir: string) => {
 if (mounted.has(mountDir)) {
 umount(mountDir);
 mounted.delete(mountDir);
 return true;
 }
 return false;
};
export const mountBrowserFS = async(mountDir: string, baseUrl: string) => {
 unmountBrowserFS(mountDir);
 const fetchFS = await resolveMountConfig({
 backend: Fetch,
 index: `${ baseUrl }/index.json`,
 baseUrl,
 disableAsyncCache: true,
 remoteWrite: true,
 });
 mount(mountDir, fetchFS);
 mounted.set(mountDir, true);
 return true;
};

And it works great. Not sure configure fits well for this, because I'm going to dynamically mount and remove filesystems depending on the project opened by the user in some SPA app.

You must be logged in to vote
0 replies
Comment options

Okay.

I'll definitely be adding a way to reload/sync the index. This could tie in nicely to the future DAV backend, since that would likely fit the use case better.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #229 on July 17, 2025 04:07.

AltStyle によって変換されたページ (->オリジナル) /