# Not possible to update file modification time through cURL (or other methods)?

**URL:** <https://help.nextcloud.com/t/not-possible-to-update-file-modification-time-through-curl-or-other-methods/85441>\
**Category:** 🏷️ General\
**Created:** [June 22, 2020, 10:10pm UTC](https://help.nextcloud.com/t/not-possible-to-update-file-modification-time-through-curl-or-other-methods/85441 "2020-06-22T22:10:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgutt](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mgutt/32/16190_2.png) [@mgutt](https://help.nextcloud.com/u/mgutt)\
**Post date:** [June 22, 2020, 10:10pm UTC](https://help.nextcloud.com/t/not-possible-to-update-file-modification-time-through-curl-or-other-methods/85441/1 "2020-06-22T22:10:21Z")

</div>

I tried many different cURL commands to upload/update files on my Nextcloud 18.0.6 server and tested which preserves the original modification timestamp (or accepts a change through the `X-OC-Mtime` header):

Uploading a file sets the upload date as file modification time (= does not preserve mtime):

```auto
curl -vs -u user:pass -T "/mnt/user/music/song.mp3" "https://example.com/remote.php/webdav/music/song.mp3" 2>&1

```

Moving the file to the same destination (overwriting) returns the Sabre DAV error “Source and destination uri are identical”:

```auto
curl -vs -X MOVE -u user:pass --header 'X-OC-Mtime: 1574254490' --header 'Destination: https://example.com/remote.php/webdav/music/song.mp3' https://example.com/remote.php/webdav/music/song.mp3 2>&1

```

Moving with overwrite command returns the Sabre DAV error “Source and destination uri are identical”:

```auto
curl -vs -X MOVE -u user:pass --header 'X-OC-Mtime: 1574254490' --header 'Overwrite: T' --header 'Destination: https://example.com/remote.php/webdav/music/song.mp3' https://example.com/remote.php/webdav/music/song.mp3 2>&1

```

Moving to a new destination ignores the X-OC-Mtime: 😢

```auto
curl -vs -X MOVE -u user:pass --header 'X-OC-Mtime: 1574254490' --header 'Destination: https://example.com/remote.php/webdav/music/song2.mp3' https://example.com/remote.php/webdav/music/song.mp3 2>&1

```

New upload with X-OC-MTime “preserves” file modification time:

```auto
curl -vs -u user:pass --header 'X-OC-Mtime: 1574254490' -T "/mnt/user/music/song.mp3" "https://example.com/remote.php/webdav/music/song.mp3" 2>&1

```

Uploading without a file overwrites the already existing file on the server by an empty file and “preserves” the modification time: 🤔

```auto
curl -vs -X PUT -u user:pass --header 'X-OC-Mtime: 1574254490' "https://example.com/remote.php/webdav/music/song.mp3" 2>&1

```

Copying the file causes a new copy timestamp (`X-OC-Mtime` has been ignored):

```auto
curl -vs -X COPY -u user:pass --header 'X-OC-Mtime: 1574254490' --header 'Destination: https://example.com/remote.php/webdav/music/song2.mp3' https://example.com/remote.php/webdav/music/song.mp3 2>&1

```

The very last command I tried was `PROPPATCH `, but I’m not sure if I did it wrong:

```auto
curl -vs -X PROPPATCH -u user:pass --header 'Content-Type: application/xml; charset="utf-8"' --data '<?xml version="1.0"?><d:propertyupdate xmlns:d="DAV:" xmlns:nc="http://nextcloud.org/ns"><d:set><d:prop><d:getlastmodified>Mon, 22 Jun 2020 19:20:21 GMT</d:getlastmodified></d:prop></d:set></d:propertyupdate>' "https://example.com/remote.php/webdav/music/song.mp3" 2>&1

```

It returns the HTTP Header “207 Multi-Status” and the following content:

```auto
<d:multistatus xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns"><d:response><d:href>/remote.php/webdav/music/song.mp3</d:href><d:propstat><d:prop><d:getlastmodified/></d:prop><d:status>HTTP/1.1 403 Forbidden</d:status></d:propstat></d:response></d:multistatus>

```

Do I really need to re-upload all my files to preserve the timestamps or did I miss a command?

---

<div class="post-metadata">

**Author:** ![mgutt](https://help.nextcloud.com/user_avatar/help.nextcloud.com/mgutt/32/16190_2.png) [@mgutt](https://help.nextcloud.com/u/mgutt)\
**Post date:** [June 23, 2020, 11:12am UTC](https://help.nextcloud.com/t/not-possible-to-update-file-modification-time-through-curl-or-other-methods/85441/2 "2020-06-23T11:12:36Z")

</div>

Ok, the PROPPATCH method (the optimum solution) does not work because a sabre/dav developer refuses to remove the protection status of the getlastmodified property (the reason why the X-OC-MTime dirty hack in Owncloud / Nextcloud even exists):

> <https://github.com/sabre-io/dav/issues/1277#issuecomment-648068415>
>
> At the moment its impossible to update the getlastmodified timestamp of a file. Sabre DAV returns an 403 Forbidden error. I...

Maybe you could support me and comment in this issue so he hopefully rethinks his decision. It doesn’t make sense that this property is protected at all. The spec says “should” and only because of rare cases to re-fill a cache.
