Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native File System API #28

Open
agentcooper opened this issue Oct 17, 2019 · 5 comments
Open

Native File System API #28

agentcooper opened this issue Oct 17, 2019 · 5 comments

Comments

@agentcooper
Copy link

Hey. I see that some work was already done in https://github.com/isomorphic-git/lightning-fs/tree/feat/native. What is the timeline for this and what are the current blockers?

For reference: https://www.chromestatus.com/feature/6284708426022912.

@billiegoose
Copy link
Member

Aha! Yes, I'm super excited about this. The current blocker is currently File handles cannot be serialized. This means they can't be sent to a Worker thread via postMessage. Which is very unfortunate, because that means you're restricted to using the main thread, which is already over burdened. All my "realistic" app architectures require using isomorphic-git and LightningFS in a worker in order to stay within performance budgets.

As soon as Chrome lands support for serializing them, I'm going to revive that branch and finish it. The other nice thing we'll be able to do is save the file handles in IndexedDb so you won't have to prompt the user with a permissions UX every time they re-open the page.

@Twaha-Rahman
Copy link

@wmhilton File handlers can be serialized and can be sent to a Worker thread via postMessage as of Chrome 83 😉

Capture

@shd101wyy
Copy link

I am currently working on a project https://github.com/0xGG/vscode-pwa and I implemented two file system providers for the vscode running on the web: One uses lightning-fs for constructing the memfs; the other one was handwritten using the native file system api.

https://github.com/0xGG/vscode-pwa also uses isomorphic-git for managing git repos. It would be great if lighting-fs can support native file system so I could better refactor my code 👍

Thanks for the awesome project!

@predmond
Copy link

predmond commented May 7, 2021

@wmhilton any updates/progress on the native branch?

@danperks
Copy link

danperks commented Mar 3, 2023

As a rudimentary solution, you can load the files manually via the File System API into LightingFS with a simple function like this one:

async function loadFiles(fs, folder, path = "/") {
  for await (const entry of folder.values()) {
  if (entry.kind === "file") {
      // Create the file
      await fs.promises.writeFile(path + entry.name, await entry.getFile());
    }
    if (entry.kind === "directory") {
      // Create the folder, then run on all files within
      await fs.promises.mkdir(path + entry.name)
      await convertFolder(entry, setRows, path + entry.name + "/");
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants