From fb38f0278d42b1de2a2f76c59aa294276aef64a1 Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Mon, 15 May 2023 19:16:22 +0200 Subject: [PATCH 1/2] webdav: fastmail: adapt modtime update to make new logic work with fastmail bring spec compliant update from: https://github.com/rclone/rclone/pull/6108 --- backend/webdav/webdav.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go index 801e8d970..c91e4950c 100644 --- a/backend/webdav/webdav.go +++ b/backend/webdav/webdav.go @@ -178,6 +178,7 @@ type Fs struct { canStream bool // set if can stream useOCMtime bool // set if can use X-OC-Mtime propsetMtime bool // set if can use propset + propNameMtime string // name of property to set for mtime retryWithZeroDepth bool // some vendors (sharepoint) won't list files when Depth is 1 (our default) checkBeforePurge bool // enables extra check that directory to purge really exists hasOCMD5 bool // set if can use owncloud style checksums for MD5 @@ -581,18 +582,22 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error { f.canStream = true f.precision = time.Second f.useOCMtime = true + f.propsetMtime = true + f.propNameMtime = "getlastmodified" f.hasMESHA1 = true case "owncloud": f.canStream = true f.precision = time.Second f.useOCMtime = true f.propsetMtime = true + f.propNameMtime = "lastmodified" f.hasOCMD5 = true f.hasOCSHA1 = true case "nextcloud": f.precision = time.Second f.useOCMtime = true f.propsetMtime = true + f.propNameMtime = "lastmodified" f.hasOCSHA1 = true f.canChunk = true @@ -1322,11 +1327,11 @@ func (o *Object) ModTime(ctx context.Context) time.Time { // Set modified time using propset // // /ocm/remote.php/webdav/office/wir.jpgHTTP/1.1 200 OK -var owncloudPropset = ` +var mtimePropset = ` - %d + %s @@ -1335,11 +1340,17 @@ var owncloudPropset = ` // SetModTime sets the modification time of the local fs object func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error { if o.fs.propsetMtime { + var modTimeStr string + if o.fs.propNameMtime == "getlastmodified" { + modTimeStr = modTime.Format(time.RFC1123) + } else { + modTimeStr = strconv.FormatInt(modTime.Unix(), 10) + } opts := rest.Opts{ Method: "PROPPATCH", Path: o.filePath(), NoRedirect: true, - Body: strings.NewReader(fmt.Sprintf(owncloudPropset, modTime.Unix())), + Body: strings.NewReader(fmt.Sprintf(mtimePropset, o.fs.propNameMtime, modTimeStr, o.fs.propNameMtime)), } var result api.Multistatus var resp *http.Response -- 2.41.0 From 84d2bbc2e2eb15f4ef3558aec46adf33d3b443c3 Mon Sep 17 00:00:00 2001 From: Jan Palus Date: Mon, 15 May 2023 19:20:32 +0200 Subject: [PATCH 2/2] webdav: fastmail: support for update_modtime config opt for compatibility with: https://github.com/rclone/rclone/pull/6108 --- backend/webdav/webdav.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go index c91e4950c..a8c7ffce8 100644 --- a/backend/webdav/webdav.go +++ b/backend/webdav/webdav.go @@ -146,6 +146,14 @@ Set to 0 to disable chunked uploading. Help: "Exclude ownCloud shares", Advanced: true, Default: false, + }, { + Name: "update_modtime", + Help: `Adjust modification time on servers which allow DAV:getlastmodified property update. + +Use provider's default if unset. +`, + Default: fs.Tristate{}, + Advanced: true, }}, }) } @@ -162,6 +170,7 @@ type Options struct { PacerMinSleep fs.Duration `config:"pacer_min_sleep"` ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"` ExcludeShares bool `config:"owncloud_exclude_shares"` + UpdateModTime fs.Tristate `config:"update_modtime"` } // Fs represents a remote webdav @@ -582,8 +591,10 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error { f.canStream = true f.precision = time.Second f.useOCMtime = true - f.propsetMtime = true - f.propNameMtime = "getlastmodified" + if !f.opt.UpdateModTime.Valid || f.opt.UpdateModTime.Valid && f.opt.UpdateModTime.Value { + f.propsetMtime = true + f.propNameMtime = "getlastmodified" + } f.hasMESHA1 = true case "owncloud": f.canStream = true -- 2.41.0