How to reset your filesystem

Written for webnative 0.35-0.36

In most cases this should be avoided, but in case you do want to risk it, here’s how you reset your filesystem.

NOTE: This could change at any time. If by the time you read this a lot of time has passed since us posting this, ask us to review this post before you undertake this reset.

Steps

  1. Go to the Fission Drive app
  2. Open up the browser console
  3. Type the following in the console.
    fs = await wn.FileSystem.empty({
      account: fs.account,
      eventEmitter: fs.eventEmitter,
      dependencies: fs.dependencies,
      rootKey: fs.root.privateNodes["private/"].key
    })
    await fs.mkdir({ directory: [ wn.path.RootBranch.Private, "Apps" ] })
    await fs.mkdir({ directory: [ wn.path.RootBranch.Private, "Audio" ] })
    await fs.mkdir({ directory: [ wn.path.RootBranch.Private, "Documents" ] })
    await fs.mkdir({ directory: [ wn.path.RootBranch.Private, "Photos" ] })
    await fs.mkdir({ directory: [ wn.path.RootBranch.Private, "Video" ] })
    await fs.publish()
    
  4. Wait till publish is finished (you should see DNSLink updated)
  5. Sign out of Drive (either by clicking sign out in menu, or clearing website data in dev tools)
  6. Sign back in.
  7. :+1:

In case fs.root.privateNodes["private/"].key fails, you can also get the rootKey from the auth lobby. There you would run await myReadKey() in the dev console to get it.

3 Likes

EDIT: Doesn’t work anymore, needs to be updated.


Alternative way, if it is a linked device you’re using.
Then you can do the following in the auth lobby:

  1. Run this in the console:
await wn.dataRoot.update(
  "Qmc5m94Gu7z62RC8waSKkZUrCCBJPyHbkpmGzEePxy2oXJ",
  await localforage.getItem("ucan")
)

:warning:This’ll reset your data root. Meaning, your account will no longer be tied to your current filesystem! This CID points to an empty file.
2. Reload the page.

There’s most likely a way to do this on a non-linked device, but I haven’t tested it. You’d need to make a UCAN yourself and use that one to authorise the request instead.

1 Like

Here’s a version that also works in case you’ve just created an account in that lobby (because then localforage.getItem("ucan") will resolve to null):

async function updateDataRoot(cid) {
    const proof = await localforage.getItem("ucan")
    const issuer = await wn.did.write()
    const fsUcan = await wn.ucan.build({
      potency: "APPEND",
      resource: "*",
      proof,
  
      audience: issuer,
      issuer
    })
  
    return wn.dataRoot.update(cid, wn.ucan.encode(fsUcan))
}

Same caveats apply as in @icidasset’s post. :slight_smile:

2 Likes