copyparty icon indicating copy to clipboard operation
copyparty copied to clipboard

Add Support for Win32LastModifiedTime WebDAV Property

Open Bip901 opened this issue 3 months ago • 4 comments

When uploading files via some WebDAV clients, Like rclone or Windows Explorer, properties such as Win32LastModifiedTime are attempted to be set, but rejected by copyparty. This results in loss of information, as the last modified timestamp of the uploaded file is changed to the upload time.

Windows Explorer HTTP request:

PROPPATCH /test.txt HTTP/1.1
<?xml version="1.0" encoding="utf-8"?>
<D:propertyupdate xmlns:D="DAV:" xmlns:Z="urn:schemas-microsoft-com:">
    <D:set>
        <D:prop>
            <Z:Win32CreationTime>Thu, 09 Oct 2025 17:54:43 GMT</Z:Win32CreationTime>
            <Z:Win32LastAccessTime>Thu, 09 Oct 2025 17:55:31 GMT</Z:Win32LastAccessTime>
            <Z:Win32LastModifiedTime>Thu, 09 Oct 2025 17:54:43 GMT</Z:Win32LastModifiedTime>
            <Z:Win32FileAttributes>00000000</Z:Win32FileAttributes>
        </D:prop>
    </D:set>
</D:propertyupdate>

Copyparty's HTTP response:

HTTP/1.1 207 Multi-Status
<D:multistatus xmlns:D="DAV:" xmlns:ns1="urn:schemas-microsoft-com:">
    <D:response>
        <D:href>/test.txt</D:href>
        <D:propstat>
            <D:prop>
                <ns1:Win32CreationTime />
                <ns1:Win32LastAccessTime />
                <ns1:Win32LastModifiedTime />
                <ns1:Win32FileAttributes />
            </D:prop>
            <D:status>HTTP/1.1 403 Forbidden</D:status>
        </D:propstat>
    </D:response>
</D:multistatus>

Bip901 avatar Oct 09 '25 18:10 Bip901

I think it would be fine to add support for setting mtime this way, but it should require the user to have the delete-permission, because I don't want someone with write-only or just read-write permissions to be able to tamper with timestamps of existing files, which proppatch does allow. Or, perhaps there could be a short grace-period (a few seconds) where such modifications are permitted just after an upload has completed.

Though, I'm curious about the rclone part; did you configure rclone as suggested on the connect-page? Specifically, did you specify owncloud as vendor? I am not seeing any PROPPATCH requests when uploading files to copyparty, only seeing this for the upload itself, and the last-modified timestamp of the uploaded file does get set correctly:

PUT /foo/bar.bin HTTP/1.1
Host: 127.0.0.1:3923
User-Agent: rclone/v1.71.1
Oc-Checksum: SHA1:6234f67362c64439b7ef175fb4df2a7839929fa0
X-Oc-Mtime: 1681086074

The reason proppatch is not currently supported is because I saw rclone would do this, which is nice because it reduces the number of roundtrips.

9001 avatar Oct 11 '25 20:10 9001

I specified 7 ("other") for rclone and mounted the webdav server via rclone as a drive letter, which I then copied to using Windows Explorer.

As for the permissions, in Linux, I noticed that you must be the owner of a file to modify its modified timestamp (to something other than the current time). If copyparty doesn't preserve ownership information for files, I reckon a grace period could be a good solution.

Bip901 avatar Oct 11 '25 21:10 Bip901

Alright -- if you change vendor to owncloud in your rclone config then it will work, and this will also enable automatic checksum verification of uploaded files.

But I will try to add support for proppatch regardless, because it will be good for other clients

9001 avatar Oct 11 '25 21:10 9001

That's good to know, thank you!

Bip901 avatar Oct 11 '25 21:10 Bip901