backend/rclone: Request random file name

When `/` is requested, rclone returns the list of all files in the
remote, which is not what we want (and it can take quite some time).
This commit is contained in:
Alexander Neumann 2018-03-18 20:30:02 +01:00
parent 360ff1806a
commit 0b776e63e7

View file

@ -5,6 +5,7 @@ import (
"context" "context"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"math/rand"
"net" "net"
"net/http" "net/http"
"net/url" "net/url"
@ -174,7 +175,11 @@ func New(cfg Config) (*Backend, error) {
Timeout: 60 * time.Second, Timeout: 60 * time.Second,
} }
req, err := http.NewRequest(http.MethodGet, "http://localhost/", nil) // request a random file which does not exist. we just want to test when
// rclone is able to accept HTTP requests.
url := fmt.Sprintf("http://localhost/file-%d", rand.Uint64())
req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }