"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
Seafile: Fix download/upload error when FILE_SERVER_ROOT is relative
DanielEgbersa0dff2dd9cc6
diff --git a/backend/seafile/webapi.go b/backend/seafile/webapi.goindex d3ebe3fde..1cc05a14b 100644--- a/backend/seafile/webapi.go+++ b/backend/seafile/webapi.go@@ -577,7 +577,7 @@ func (f *Fs) getDownloadLink(ctx context.Context, libraryID, filePath string) (sreturn result, nil}-func (f *Fs) download(ctx context.Context, url string, size int64, options ...fs.OpenOption) (io.ReadCloser, error) {+func (f *Fs) download(ctx context.Context, downloadLink string, size int64, options ...fs.OpenOption) (io.ReadCloser, error) {// Check if we need to download partial contentvar start, end int64 = 0, sizepartialContent := false@@ -606,11 +606,18 @@ func (f *Fs) download(ctx context.Context, url string, size int64, options ...fs// Build the http requestopts := rest.Opts{Method: "GET",- RootURL: url,Options: options,}+ parsedURL, err := url.Parse(downloadLink)+ if err != nil {+ return nil, fmt.Errorf("failed to parse download url: %w", err)+ }+ if parsedURL.IsAbs() {+ opts.RootURL = downloadLink+ } else {+ opts.Path = downloadLink+ }var resp *http.Response- var err errorerr = f.pacer.Call(func() (bool, error) {resp, err = f.srv.Call(ctx, &opts)return f.shouldRetry(ctx, resp, err)@@ -618,7 +625,7 @@ func (f *Fs) download(ctx context.Context, url string, size int64, options ...fsif err != nil {if resp != nil {if resp.StatusCode == 404 {- return nil, fmt.Errorf("file not found '%s'", url)+ return nil, fmt.Errorf("file not found '%s'", downloadLink)}}return nil, err@@ -688,11 +695,19 @@ func (f *Fs) upload(ctx context.Context, in io.Reader, uploadLink, filePath striopts := rest.Opts{Method: "POST",- RootURL: uploadLink,Body: formReader,ContentType: contentType,Parameters: url.Values{"ret-json": {"1"}}, // It needs to be on the url, not in the body parameters}+ parsedURL, err := url.Parse(uploadLink)+ if err != nil {+ return nil, fmt.Errorf("failed to parse upload url: %w", err)+ }+ if parsedURL.IsAbs() {+ opts.RootURL = uploadLink+ } else {+ opts.Path = uploadLink+ }result := make([]api.FileDetail, 1)var resp *http.Response// If an error occurs during the call, do not attempt to retry: The upload link is single use only