]> git.pld-linux.org Git - packages/rclone.git/blame - webdav-modtime.patch
up to 1.66.0
[packages/rclone.git] / webdav-modtime.patch
CommitLineData
2078caf7 1From fb38f0278d42b1de2a2f76c59aa294276aef64a1 Mon Sep 17 00:00:00 2001
a5880a6d 2From: Jan Palus <jpalus@fastmail.com>
594aadbf
JP
3Date: Mon, 15 May 2023 19:16:22 +0200
4Subject: [PATCH 1/2] webdav: fastmail: adapt modtime update
a5880a6d 5
594aadbf
JP
6to make new logic work with fastmail bring spec compliant update from:
7https://github.com/rclone/rclone/pull/6108
a5880a6d 8---
594aadbf
JP
9 backend/webdav/webdav.go | 17 ++++++++++++++---
10 1 file changed, 14 insertions(+), 3 deletions(-)
a5880a6d
JP
11
12diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
2078caf7 13index 801e8d970..c91e4950c 100644
a5880a6d
JP
14--- a/backend/webdav/webdav.go
15+++ b/backend/webdav/webdav.go
2078caf7 16@@ -178,6 +178,7 @@ type Fs struct {
594aadbf
JP
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
2078caf7 24@@ -581,18 +582,22 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
594aadbf
JP
25 f.canStream = true
26 f.precision = time.Second
27 f.useOCMtime = true
28+ f.propsetMtime = true
29+ f.propNameMtime = "getlastmodified"
30 f.hasMESHA1 = true
31 case "owncloud":
32 f.canStream = true
33 f.precision = time.Second
34 f.useOCMtime = true
35 f.propsetMtime = true
36+ f.propNameMtime = "lastmodified"
37 f.hasOCMD5 = true
38 f.hasOCSHA1 = true
39 case "nextcloud":
40 f.precision = time.Second
41 f.useOCMtime = true
42 f.propsetMtime = true
43+ f.propNameMtime = "lastmodified"
44 f.hasOCSHA1 = true
45 f.canChunk = true
2078caf7
JP
46
47@@ -1322,11 +1327,11 @@ func (o *Object) ModTime(ctx context.Context) time.Time {
594aadbf 48 // Set modified time using propset
a5880a6d 49 //
594aadbf
JP
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:">
54 <D:set>
55 <D:prop>
56- <lastmodified xmlns="DAV:">%d</lastmodified>
57+ <D:%s>%s</D:%s>
58 </D:prop>
59 </D:set>
60 </D:propertyupdate>
2078caf7 61@@ -1335,11 +1340,17 @@ var owncloudPropset = `<?xml version="1.0" encoding="utf-8" ?>
a5880a6d
JP
62 // SetModTime sets the modification time of the local fs object
63 func (o *Object) SetModTime(ctx context.Context, modTime time.Time) error {
594aadbf
JP
64 if o.fs.propsetMtime {
65+ var modTimeStr string
66+ if o.fs.propNameMtime == "getlastmodified" {
67+ modTimeStr = modTime.Format(time.RFC1123)
68+ } else {
69+ modTimeStr = strconv.FormatInt(modTime.Unix(), 10)
a5880a6d 70+ }
594aadbf
JP
71 opts := rest.Opts{
72 Method: "PROPPATCH",
73 Path: o.filePath(),
74 NoRedirect: true,
75- Body: strings.NewReader(fmt.Sprintf(owncloudPropset, modTime.Unix())),
76+ Body: strings.NewReader(fmt.Sprintf(mtimePropset, o.fs.propNameMtime, modTimeStr, o.fs.propNameMtime)),
77 }
78 var result api.Multistatus
79 var resp *http.Response
a5880a6d 80--
594aadbf 812.41.0
a5880a6d 82
2078caf7 83From 84d2bbc2e2eb15f4ef3558aec46adf33d3b443c3 Mon Sep 17 00:00:00 2001
a5880a6d 84From: Jan Palus <jpalus@fastmail.com>
594aadbf
JP
85Date: Mon, 15 May 2023 19:20:32 +0200
86Subject: [PATCH 2/2] webdav: fastmail: support for update_modtime config opt
a5880a6d 87
594aadbf
JP
88for compatibility with:
89https://github.com/rclone/rclone/pull/6108
a5880a6d 90---
594aadbf
JP
91 backend/webdav/webdav.go | 15 +++++++++++++--
92 1 file changed, 13 insertions(+), 2 deletions(-)
a5880a6d
JP
93
94diff --git a/backend/webdav/webdav.go b/backend/webdav/webdav.go
2078caf7 95index c91e4950c..a8c7ffce8 100644
a5880a6d
JP
96--- a/backend/webdav/webdav.go
97+++ b/backend/webdav/webdav.go
2078caf7 98@@ -146,6 +146,14 @@ Set to 0 to disable chunked uploading.
3c8921e4 99 Help: "Exclude ownCloud shares",
a5880a6d 100 Advanced: true,
3c8921e4 101 Default: false,
594aadbf 102+ }, {
a5880a6d
JP
103+ Name: "update_modtime",
104+ Help: `Adjust modification time on servers which allow DAV:getlastmodified property update.
105+
106+Use provider's default if unset.
107+`,
108+ Default: fs.Tristate{},
594aadbf 109+ Advanced: true,
a5880a6d
JP
110 }},
111 })
594aadbf 112 }
2078caf7 113@@ -162,6 +170,7 @@ type Options struct {
594aadbf
JP
114 PacerMinSleep fs.Duration `config:"pacer_min_sleep"`
115 ChunkSize fs.SizeSuffix `config:"nextcloud_chunk_size"`
3c8921e4 116 ExcludeShares bool `config:"owncloud_exclude_shares"`
a5880a6d
JP
117+ UpdateModTime fs.Tristate `config:"update_modtime"`
118 }
119
120 // Fs represents a remote webdav
2078caf7 121@@ -582,8 +591,10 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
594aadbf
JP
122 f.canStream = true
123 f.precision = time.Second
124 f.useOCMtime = true
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"
a5880a6d 130+ }
594aadbf
JP
131 f.hasMESHA1 = true
132 case "owncloud":
133 f.canStream = true
a5880a6d 134--
594aadbf 1352.41.0
a5880a6d 136
This page took 0.090599 seconds and 4 git commands to generate.