]> git.pld-linux.org Git - packages/rclone.git/blob - webdav-modtime.patch
up to 1.66.0
[packages/rclone.git] / webdav-modtime.patch
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
5
6 to make new logic work with fastmail bring spec compliant update from:
7 https://github.com/rclone/rclone/pull/6108
8 ---
9  backend/webdav/webdav.go | 17 ++++++++++++++---
10  1 file changed, 14 insertions(+), 3 deletions(-)
11
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 {
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
46  
47 @@ -1322,11 +1327,11 @@ func (o *Object) ModTime(ctx context.Context) time.Time {
48  // Set modified time using propset
49  //
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>
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)
68 +               } else {
69 +                       modTimeStr = strconv.FormatInt(modTime.Unix(), 10)
70 +               }
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
80 -- 
81 2.41.0
82
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
87
88 for compatibility with:
89 https://github.com/rclone/rclone/pull/6108
90 ---
91  backend/webdav/webdav.go | 15 +++++++++++++--
92  1 file changed, 13 insertions(+), 2 deletions(-)
93
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",
100                         Advanced: true,
101                         Default:  false,
102 +               }, {
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{},
109 +                       Advanced: true,
110                 }},
111         })
112  }
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"`
118  }
119  
120  // Fs represents a remote webdav
121 @@ -582,8 +591,10 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
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"
130 +               }
131                 f.hasMESHA1 = true
132         case "owncloud":
133                 f.canStream = true
134 -- 
135 2.41.0
136
This page took 0.211917 seconds and 3 git commands to generate.