mirror of
https://github.com/rclone/rclone.git
synced 2025-08-19 09:52:05 +02:00
webdav: nextcloud: fix must use /dav/files/USER endpoint not /webdav error
Fix https://github.com/rclone/rclone/issues/7103 Before this change the RegExp validating the endpoint URL was a bit too strict allowing only /dav/files/USER due to chunking limitations. This patch adds back support for /dav/files/USER/dir/subdir etc. Co-authored-by: Nick Craig-Wood <nick@craig-wood.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/lib/readers"
|
||||
@@ -41,10 +40,6 @@ func (f *Fs) setUploadChunkSize(cs fs.SizeSuffix) (old fs.SizeSuffix, err error)
|
||||
return
|
||||
}
|
||||
|
||||
func (f *Fs) getChunksUploadURL() string {
|
||||
return strings.Replace(f.endpointURL, "/dav/files/", "/dav/uploads/", 1)
|
||||
}
|
||||
|
||||
func (o *Object) getChunksUploadDir() (string, error) {
|
||||
hasher := md5.New()
|
||||
_, err := hasher.Write([]byte(o.filePath()))
|
||||
@@ -55,12 +50,16 @@ func (o *Object) getChunksUploadDir() (string, error) {
|
||||
return uploadDir, nil
|
||||
}
|
||||
|
||||
func (f *Fs) verifyChunkConfig() error {
|
||||
if f.opt.ChunkSize != 0 && !validateNextCloudChunkedURL.MatchString(f.endpointURL) {
|
||||
return errors.New("chunked upload with nextcloud must use /dav/files/USER endpoint not /webdav")
|
||||
func (f *Fs) getChunksUploadURL() (string, error) {
|
||||
submatch := nextCloudURLRegex.FindStringSubmatch(f.endpointURL)
|
||||
if submatch == nil {
|
||||
return "", errors.New("the remote url looks incorrect. Note that nextcloud chunked uploads require you to use the /dav/files/USER endpoint instead of /webdav")
|
||||
}
|
||||
|
||||
return nil
|
||||
baseURL, user := submatch[1], submatch[2]
|
||||
chunksUploadURL := fmt.Sprintf("%s/dav/uploads/%s/", baseURL, user)
|
||||
|
||||
return chunksUploadURL, nil
|
||||
}
|
||||
|
||||
func (o *Object) shouldUseChunkedUpload(src fs.ObjectInfo) bool {
|
||||
|
Reference in New Issue
Block a user