Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

feature: ipfs.files.exists #146

Closed
daviddias opened this issue Jul 7, 2017 · 3 comments
Closed

feature: ipfs.files.exists #146

daviddias opened this issue Jul 7, 2017 · 3 comments

Comments

@daviddias
Copy link
Contributor

Following proposal on ipfs/js-ipfs#780 by @aphelionz, we would have:

A files.exists might be indeed useful, but also misleading, it should include options for:

  • local
  • check only root (avoid recursively checking all the leafs)
@aphelionz
Copy link

Thanks @diasdavid

@Kubuxu
Copy link

Kubuxu commented Jul 10, 2017

I am not sure if it is needed in the files namespace as you can pull out the hash of the file using files.stat and then use generic command to check of availability.

The command for checking that doesn't exist currently and doing it outside of files command-space would be more generic approach.

@achingbrain
Copy link
Collaborator

I don't think we should do this for similar reasons to why fs.exists is deprecated in node core:

Using fs.exists() to check for the existence of a file before calling fs.open(), fs.readFile() or fs.writeFile() is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file does not exist.

A user can simulate it with ipfs.files.stat(pathOrCID) but we should not encourage it's use.

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

No branches or pull requests

4 participants