Skip to content
This repository has been archived by the owner. It is now read-only.

Reverse refs (or how to find parent hash) #95

Closed
lockedshadow opened this issue Feb 15, 2016 · 2 comments
Closed

Reverse refs (or how to find parent hash) #95

lockedshadow opened this issue Feb 15, 2016 · 2 comments
Labels

Comments

@lockedshadow
Copy link

lockedshadow commented Feb 15, 2016

First of all, apologize for my bad english. Hope that you can understand it.

For example, we created directory named «foo» and put to it files named «bar», «baz», then pinned them recursively by ipfs add command, like this:

mkdir foo
echo bar > ./foo/bar
echo baz > ./foo/baz
ipfs add -r ./foo

And next we have result:

added QmTz3oc4gdpRMKP2sdGUPZTAGRngqjsi99BPoztyP53JMM foo/bar
added QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR foo/baz
added QmRoqGfDXiwoUBMTKtU9Hbd8W1DTbSGZ4rJmUGtmNXbgY2 foo

Is there an easy way to determine hash of directory «foo» and other pinned directories which contains this objects, if now we know only hashes of «bar» and «baz» (QmTz3oc4gdpRMKP2sdGUPZTAGRngqjsi99BPoztyP53JMM and QmWLdkp93sNxGRjnFHPaYg8tCQ35NBY3XPn6KiETd3Z4WR)? Something like ipfs refs --reverse command.

(At least we can use this workaround: for hash in $(ipfs pin ls -q) ; do ipfs refs -e $hash | grep [hash] ; done, but maybe built-in solution available?)

@lernisto
Copy link

lernisto commented Feb 26, 2016

A "directory" is just a set of links to other hashes. It is not possible to include a ".." ref in the directory, because such a reference would introduce a cycle into the DAG. A hash is somewhat like a private key in that if you lose it, there is no general way to recover it (short of re-hashing the content). Your workaround is probably the best solution, if you don't want to store the parent hash in IPNS.

@flyingzumwalt
Copy link
Contributor

flyingzumwalt commented May 23, 2017

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

No branches or pull requests

4 participants