From 44e83d77d754aef3b4408edf62f5943d1c979a8c Mon Sep 17 00:00:00 2001 From: nielash Date: Thu, 6 Mar 2025 08:15:51 -0500 Subject: [PATCH] http: correct root if definitely pointing to a file - fixes #8428 This was formalized in https://github.com/rclone/rclone/commit/c69eb84573c85206ab028eda2987180e049ef2e4 But it appears that we forgot to update `http`, and the `FsRoot` test didn't catch it because we don't currently have an http integration test. --- backend/http/http.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/http/http.go b/backend/http/http.go index 4b64ec304..d4b426a7f 100644 --- a/backend/http/http.go +++ b/backend/http/http.go @@ -180,7 +180,6 @@ func getFsEndpoint(ctx context.Context, client *http.Client, url string, opt *Op } addHeaders(req, opt) res, err := noRedir.Do(req) - if err != nil { fs.Debugf(nil, "Assuming path is a file as HEAD request could not be sent: %v", err) return createFileResult() @@ -249,6 +248,14 @@ func (f *Fs) httpConnection(ctx context.Context, opt *Options) (isFile bool, err f.httpClient = client f.endpoint = u f.endpointURL = u.String() + + if isFile { + // Correct root if definitely pointing to a file + f.root = path.Dir(f.root) + if f.root == "." || f.root == "/" { + f.root = "" + } + } return isFile, nil }