Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

How to clear browser local stored data? #2005

Closed
bruinxs opened this issue Apr 23, 2019 · 4 comments
Closed

How to clear browser local stored data? #2005

bruinxs opened this issue Apr 23, 2019 · 4 comments

Comments

@bruinxs
Copy link

bruinxs commented Apr 23, 2019

  • Version: 0.34.4
  • Platform: browser
  • Subsystem: files

Type: Question

Severity: Low

Description:

I want to clear some of the data stored in the browser by ipfs, preventing excessive data usage and causing possible exceptions. But the ipfs.repo.gc interface is not implemented, then I use ipfs.files.rm, but how do I change it?

For example, I want to delete QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk and all leaf nodes, call ipfs.files.rm('/ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk', {recursive: true}) will report an error.

Steps to reproduce the error:

> await ipfs.files.stat('/ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk', {withLocal: true})
{
  blocks: 0,
  cumulativeSize: 107507,
  hash: "QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk",
  local: undefined,
  size: 107493,
  sizeLocal: undefined,
  type: "file",
  withLocality: false
}
> await ipfs.files.rm('/ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk', {recursive: true})
rm.js:59 Uncaught (in promise) Error: /ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk does not exist Error: /ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk does not exist
    at waterfall (rm.js:58)
    at nextTask (waterfall.js:16)
    at next (waterfall.js:23)
    at onlyOnce.js:12
    at toTrail (rm.js:52)
    at reduce.js:10
    at drain.js:20
    at map.js:19
    at filter.js:17
    at map.js:19
@reasv
Copy link
Contributor

reasv commented Apr 28, 2019

ipfs.files.rm operates on the Mutable File System (MFS). You cannot use it to delete an IPFS object by CID, like '/ipfs/QmZdXoMy8Gvis99qmGtHH4Q8YaUTwZrC5G7hRiLcMwrnVk'

@alx696
Copy link

alx696 commented Apr 29, 2019

@bruinxs Chrome中按F12进Application标签, 数据应该在IndexedDB中. 所以清除IndexedDB即可, 或者清楚浏览器缓存.

@bruinxs
Copy link
Author

bruinxs commented Apr 30, 2019

@alx696 Thank you, but I hope to automatically erase unused data in the production environment.

@alanshaw
Copy link
Member

alanshaw commented May 3, 2019

Just to reiterate what @reasv said, files.rm is for removing files from your MFS tree not for removing blocks from your repo. Garbage collection is what you need for this and it is being worked on right now. You can follow progress here #2012

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

No branches or pull requests

4 participants