aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/manifest.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/api/manifest.go')
-rw-r--r--swarm/api/manifest.go32
1 files changed, 28 insertions, 4 deletions
diff --git a/swarm/api/manifest.go b/swarm/api/manifest.go
index 90f287677..d3eced198 100644
--- a/swarm/api/manifest.go
+++ b/swarm/api/manifest.go
@@ -22,6 +22,8 @@ import (
"errors"
"fmt"
"io"
+ "net/http"
+ "strings"
"sync"
"time"
@@ -422,25 +424,47 @@ func (self *manifestTrie) findPrefixOf(path string, quitC chan bool) (entry *man
return self.entries[256], 0
}
+ //see if first char is in manifest entries
b := byte(path[0])
entry = self.entries[b]
if entry == nil {
return self.entries[256], 0
}
+
epl := len(entry.Path)
log.Trace(fmt.Sprintf("path = %v entry.Path = %v epl = %v", path, entry.Path, epl))
- if (len(path) >= epl) && (path[:epl] == entry.Path) {
+ if len(path) <= epl {
+ if entry.Path[:len(path)] == path {
+ if entry.ContentType == ManifestType {
+ entry.Status = http.StatusMultipleChoices
+ }
+ pos = len(path)
+ return
+ }
+ return nil, 0
+ }
+ if path[:epl] == entry.Path {
log.Trace(fmt.Sprintf("entry.ContentType = %v", entry.ContentType))
- if entry.ContentType == ManifestType {
+ //the subentry is a manifest, load subtrie
+ if entry.ContentType == ManifestType && (strings.Contains(entry.Path, path) || strings.Contains(path, entry.Path)) {
err := self.loadSubTrie(entry, quitC)
if err != nil {
return nil, 0
}
- entry, pos = entry.subtrie.findPrefixOf(path[epl:], quitC)
- if entry != nil {
+ sub, pos := entry.subtrie.findPrefixOf(path[epl:], quitC)
+ if sub != nil {
+ entry = sub
pos += epl
+ return sub, pos
+ } else if path == entry.Path {
+ entry.Status = http.StatusMultipleChoices
}
+
} else {
+ //entry is not a manifest, return it
+ if path != entry.Path {
+ return nil, 0
+ }
pos = epl
}
}