} else {
if currentSpan[1] == fss.SegPos {
currentSpan[1] += fss.SegLen
+ } else if currentSpan[0]+currentSpan[1] == fss.SegPos {
+ currentSpan[1] = fss.SegPos + fss.SegLen
} else {
manifestForPath += fmt.Sprintf("%v", currentSpan[0]) + ":" + fmt.Sprintf("%v", currentSpan[1]+fss.SegLen) + ":" + fss.Name + " "
currentSpan = []uint64{fss.SegPos, fss.SegPos + fss.SegLen}
}
}
}
+
+func TestNormalizeManifest(t *testing.T) {
+ m := Manifest{Text: ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:10:one 10:10:one 20:10:two 30:10:two\n"}
+ normalized := m.NormalizedManifestForPath("")
+ expectEqual(t, normalized, ". acbd18db4cc2f85cedef654fccc4a4d8+40 0:20:one 20:40:two\n")
+}
manifestText = strings.Replace(collection.ManifestText, "./", "."+bindSuffix+"/", -1)
manifestText = strings.Replace(manifestText, ". ", "."+bindSuffix+" ", -1)
wanted := ""
- for _, token := range strings.Split(manifestText, " ") {
- if strings.Index(token, ":") == -1 {
- wanted += " " + token
- } else if strings.Index(token, ":"+mntPath) >= 0 {
- wanted += " " + token + "\n"
- break
+ for _, stream := range strings.Split(manifestText, "\n") {
+ if strings.Index(stream, mntPath) == -1 {
+ continue
+ }
+
+ for _, token := range strings.Split(manifestText, " ") {
+ if strings.Index(token, ":") == -1 {
+ wanted += " " + token
+ } else if strings.Index(token, ":"+mntPath) >= 0 {
+ wanted += " " + token + "\n"
+ break
+ }
}
}
return wanted, nil