The issue description is generated by Claude and reviewed/modified by me
Summary
When uploading files to a WebDAV server, Material Files does not preserve the original file modification time (mtime). The server receives PROPFIND and PUT requests, but no mtime-setting mechanism is used. This can be addressed by sending the X-OC-MTime request header alongside PUT.
Why PROPPATCH on getlastmodified does not work
This is a plausible approach. However, RFC 4918 §15.7 specifies that {DAV:}getlastmodified "SHOULD be protected because some clients may rely on the value for appropriate caching behavior, or on the value of the Last-Modified header to which this property is linked." (RFC 4918 §15.7)
In practice, most WebDAV servers implement this recommendation and reject PROPPATCH on getlastmodified with 403 Forbidden. Apache mod_dav, sabre/dav (sabre/dav issue #1277), and others all protect this property by default.
The X-OC-MTime header
Specification
The X-OC-MTime header is a WebDAV extension for setting resource modification time during PUT. It is documented in the ownCloud developer API reference:
Request header: X-OC-Mtime: <unix-timestamp> — an integer Unix timestamp (seconds since epoch) sent with a PUT request.
Response header: X-OC-Mtime: accepted — returned by the server if the mtime was successfully applied.
(ownCloud WebDAV API reference — Upload File)
Example from the ownCloud documentation:
PUT /dav/spaces/.../test.txt HTTP/1.1
X-OC-Mtime: 1692369418
...
HTTP/1.1 204 No Content
X-Oc-Mtime: accepted
Last-Modified: Fri, 18 Aug 2023 14:36:58 +0000
Server support
The header is now supported by a range of WebDAV servers:
Client support
Existing WebDAV clients that send X-OC-MTime include the Nextcloud desktop client, rclone (when vendor is set to owncloud, nextcloud, or fastmail), and Cyberduck / Mountain Duck.
Proposed behavior
When uploading a file to a WebDAV server, Material Files should include the X-OC-MTime header in the PUT request with the source file's modification time as an integer Unix timestamp in seconds:
If the server responds with X-OC-MTime: accepted, the mtime was successfully applied. If the header is absent from the response, it can be silently ignored. Servers that do not recognize the header will ignore it, so sending it unconditionally is safe.
Scope
This request covers PUT only. MOVE and COPY operations are out of scope, as X-OC-MTime is not defined for those methods in existing implementations either.
The issue description is generated by Claude and reviewed/modified by me
Summary
When uploading files to a WebDAV server, Material Files does not preserve the original file modification time (
mtime). The server receivesPROPFINDandPUTrequests, but no mtime-setting mechanism is used. This can be addressed by sending theX-OC-MTimerequest header alongsidePUT.Why
PROPPATCHongetlastmodifieddoes not workThis is a plausible approach. However, RFC 4918 §15.7 specifies that
{DAV:}getlastmodified"SHOULD be protected because some clients may rely on the value for appropriate caching behavior, or on the value of theLast-Modifiedheader to which this property is linked." (RFC 4918 §15.7)In practice, most WebDAV servers implement this recommendation and reject
PROPPATCHongetlastmodifiedwith403 Forbidden. Apachemod_dav, sabre/dav (sabre/dav issue #1277), and others all protect this property by default.The
X-OC-MTimeheaderSpecification
The
X-OC-MTimeheader is a WebDAV extension for setting resource modification time duringPUT. It is documented in the ownCloud developer API reference:(ownCloud WebDAV API reference — Upload File)
Example from the ownCloud documentation:
Server support
The header is now supported by a range of WebDAV servers:
mod_dav(trunk/2.5)DavHonorMtimeHeaderdirective — commit 2d92bae, mod_dav docsserve webdavClient support
Existing WebDAV clients that send
X-OC-MTimeinclude the Nextcloud desktop client, rclone (when vendor is set toowncloud,nextcloud, orfastmail), and Cyberduck / Mountain Duck.Proposed behavior
When uploading a file to a WebDAV server, Material Files should include the
X-OC-MTimeheader in thePUTrequest with the source file's modification time as an integer Unix timestamp in seconds:If the server responds with
X-OC-MTime: accepted, the mtime was successfully applied. If the header is absent from the response, it can be silently ignored. Servers that do not recognize the header will ignore it, so sending it unconditionally is safe.Scope
This request covers
PUTonly.MOVEandCOPYoperations are out of scope, asX-OC-MTimeis not defined for those methods in existing implementations either.