1 From fb38f0278d42b1de2a2f76c59aa294276aef64a1 Mon Sep 17 00:00:00 2001
2 From: Jan Palus <jpalus@fastmail.com>
3 Date: Mon, 15 May 2023 19:16:22 +0200
4 Subject: [PATCH 1/2] webdav: fastmail: adapt modtime update
6 to make new logic work with fastmail bring spec compliant update from:
7 https://github.com/rclone/rclone/pull/6108
9 backend/webdav/webdav.go | 17 ++++++++++++++---
10 1 file changed, 14 insertions(+), 3 deletions(-)
12 diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
13 index 801e8d970..c91e4950c 100644
14 --- a/backend/webdav/webdav.go
15 +++ b/backend/webdav/webdav.go
16 @@ -178,6 +178,7 @@ type Fs struct {
17 canStream bool // set if can stream
18 useOCMtime bool // set if can use X-OC-Mtime
19 propsetMtime bool // set if can use propset
20 + propNameMtime string // name of property to set for mtime
21 retryWithZeroDepth bool // some vendors (sharepoint) won't list files when Depth is 1 (our default)
22 checkBeforePurge bool // enables extra check that directory to purge really exists
23 hasOCMD5 bool // set if can use owncloud style checksums for MD5
24 @@ -581,18 +582,22 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
26 f.precision = time.Second
28 + f.propsetMtime = true
29 + f.propNameMtime = "getlastmodified"
33 f.precision = time.Second
36 + f.propNameMtime = "lastmodified"
40 f.precision = time.Second
43 + f.propNameMtime = "lastmodified"
47 @@ -1322,11 +1327,11 @@ func (o *Object) ModTime(ctx context.Context) time.Time {
48 // Set modified time using propset
50 // <d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:response><d:href>/ocm/remote.php/webdav/office/wir.jpg</d:href><d:propstat><d:prop><d:lastmodified/></d:prop><d:status>HTTP/1.1 200 OK</d:status></d:propstat></d:response></d:multistatus>
51 -var owncloudPropset = `<?xml version="1.0" encoding="utf-8" ?>
52 +var mtimePropset = `<?xml version="1.0" encoding="utf-8" ?>
53 <D:propertyupdate xmlns:D="DAV:">
56 - <lastmodified xmlns="DAV:">%d</lastmodified>
61 @@ -1335,11 +1340,17 @@ var owncloudPropset = `<?xml version="1.0" encoding="utf-8" ?>
62 // SetModTime sets the modification time of the local fs object
63 func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
64 if o.fs.propsetMtime {
65 + var modTimeStr string
66 + if o.fs.propNameMtime == "getlastmodified" {
67 + modTimeStr = modTime.Format(time.RFC1123)
69 + modTimeStr = strconv.FormatInt(modTime.Unix(), 10)
75 - Body: strings.NewReader(fmt.Sprintf(owncloudPropset, modTime.Unix())),
76 + Body: strings.NewReader(fmt.Sprintf(mtimePropset, o.fs.propNameMtime, modTimeStr, o.fs.propNameMtime)),
78 var result api.Multistatus
79 var resp *http.Response
83 From 84d2bbc2e2eb15f4ef3558aec46adf33d3b443c3 Mon Sep 17 00:00:00 2001
84 From: Jan Palus <jpalus@fastmail.com>
85 Date: Mon, 15 May 2023 19:20:32 +0200
86 Subject: [PATCH 2/2] webdav: fastmail: support for update_modtime config opt
88 for compatibility with:
89 https://github.com/rclone/rclone/pull/6108
91 backend/webdav/webdav.go | 15 +++++++++++++--
92 1 file changed, 13 insertions(+), 2 deletions(-)
94 diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
95 index c91e4950c..a8c7ffce8 100644
96 --- a/backend/webdav/webdav.go
97 +++ b/backend/webdav/webdav.go
98 @@ -146,6 +146,14 @@ Set to 0 to disable chunked uploading.
99 Help: "Exclude ownCloud shares",
103 + Name: "update_modtime",
104 + Help: `Adjust modification time on servers which allow DAV:getlastmodified property update.
106 +Use provider's default if unset.
108 + Default: fs.Tristate{},
113 @@ -162,6 +170,7 @@ type Options struct {
114 PacerMinSleep fs.Duration `config:"pacer_min_sleep"`
115 ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"`
116 ExcludeShares bool `config:"owncloud_exclude_shares"`
117 + UpdateModTime fs.Tristate `config:"update_modtime"`
120 // Fs represents a remote webdav
121 @@ -582,8 +591,10 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
123 f.precision = time.Second
125 - f.propsetMtime = true
126 - f.propNameMtime = "getlastmodified"
127 + if !f.opt.UpdateModTime.Valid || f.opt.UpdateModTime.Valid && f.opt.UpdateModTime.Value {
128 + f.propsetMtime = true
129 + f.propNameMtime = "getlastmodified"