-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix breakage: t0080-repo refs local bug #994
Comments
in your instrumentation you should try and break out the ipfs key and print it so we can see the |
@whyrusleeping it's there-- oh no it isn't. okay, maybe it is our bug after all. le sigh |
Maybe the breakage in PR #933 is related? |
this issue is caused by the path.Clean bug in go-datastore. Any key that ends in a '/' character will be mangled. This is a fairly major bug honestly |
So what can we do about that? Is there already an opened go-datastore issue about it? |
I thought there was, but I don't see one. I think that we shouldnt be using the go-datastore, and instead should be using something better tailored to a content addressed file store. |
@whyrusleeping @jbenet @chriscool To sum up - problems arise when the binary hash contains ascii symbols
Any of these files can never be properly garbage collected because a proper key can not be reconstructed from the file name. Since migrating to a new datastore is quite an ambitious task, here is a temporary solution. It has to do with customizing the
func (k *Key) Clean() {
// k.string = path.Clean("/" + k.string)
s := "/" + k.string
lk := len(s)
bb := bytes.NewBuffer(make([]byte, 0, lk*2))
lastb := 0 // last index saved to buffer
kmap := make(map [string]string)
for i := 1; i < lk - 1; i++ {
if s[i-1] != '/' || !mh.ValidCode(int(s[i])) {
continue
}
mhend := i + 2 + int(s[i+1]) // end index of hash
if mhend > lk {
continue
}
if mhend == lk || s[mhend] == '/' {
// end-of-string or has slash at the end
rawh := s[i:mhend]
hexh := hex.EncodeToString([]byte(rawh))
kmap[hexh] = rawh
bb.WriteString(s[lastb:i]) // copy since last copy
bb.WriteString(hexh)
lastb = mhend
i = mhend
}
}
if lastb > 0 {
if lastb < lk {
bb.WriteString(s[lastb:lk])
}
// clean
s = path.Clean(bb.String())
// replace hex with raw hashes
for hexh, rawh := range kmap {
s = strings.Replace(s, hexh, rawh, -1)
}
} else {
// no hashes in key
s = path.Clean(s)
}
k.string = s
} I know it is not a pretty solution since go-datastore is more or less abstract and shouldn't even know that part of the keys might be multihashes, but at least the solution works and is just a bunch of lines of code. Potential problems:
|
This has been fixed in #2903 |
See #992 (comment)
Looks to be a bug in syndtr/leveldb given https://gist.github.com/jbenet/adf77b142a78451d1f91
The text was updated successfully, but these errors were encountered: