Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

http: remove duplicates from listings

Nick Craig-Wood54a2e99d97b6
diff --git a/backend/http/http.go b/backend/http/http.go
index c155f31fc..c42049972 100644
--- a/backend/http/http.go
+++ b/backend/http/http.go
@@ -270,14 +270,20 @@ func parse(base *url.URL, in io.Reader) (names []string, err error) {
if err != nil {
return nil, err
}
- var walk func(*html.Node)
+ var (
+ walk func(*html.Node)
+ seen = make(map[string]struct{})
+ )
walk = func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "a" {
for _, a := range n.Attr {
if a.Key == "href" {
name, err := parseName(base, a.Val)
if err == nil {
- names = append(names, name)
+ if _, found := seen[name]; !found {
+ names = append(names, name)
+ seen[name] = struct{}{}
+ }
}
break
}