Rclone copy repeatedly copies some unchanged files

It seems like we are getting somewhere!

I managed to reproduce this problem locally with onedrive business - it did not reproduce with onedrive personal.

cd /tmp
mkdir onedrive-issue
mkdir onedrive-issue/_layouts
echo hello > onedrive-issue/_layouts/test.log
echo hellohello > onedrive-issue/_layouts/default.html
rclone copy -vv --no-traverse  onedrive-issue onedrive:onedrive-issue
rclone copy -vv --no-traverse  onedrive-issue onedrive:onedrive-issue

This is making me think this is a bug in Onedrive Business (It wouln't be the first issue I've found with rclone!)

With --no-traverse rclone will check for the presense of each file individually, rather than listing the directory.

The call it uses is this

2022/02/21 11:54:37 DEBUG : HTTP REQUEST (req 0xc000736100)
2022/02/21 11:54:37 DEBUG : GET /v1.0/drives/b!tPczmrJTCE2ShO96VLAAn_DGv2_4eZJGl83N0OQe_t9LuHcGPileQ7YByS0_6_xp/root:/onedrive-issue/_layouts/default.html HTTP/1.1
Host: graph.microsoft.com
User-Agent: rclone/v1.58.0-beta.6000.04177102c.fix-5984-vfs-rename-open
Authorization: XXXX
Accept-Encoding: gzip

And the response from onedrive business is 404 not found

2022/02/21 11:54:38 DEBUG : HTTP RESPONSE (req 0xc000736100)
2022/02/21 11:54:38 DEBUG : HTTP/1.1 404 Not Found
Transfer-Encoding: chunked
Client-Request-Id: ca107748-f71a-4f2c-a492-76ce4057406a
Content-Type: application/json
Date: Mon, 21 Feb 2022 11:54:37 GMT
Request-Id: ca107748-f71a-4f2c-a492-76ce4057406a
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Ms-Ags-Diagnostic: {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"001","RoleInstance":"LN2PEPF00006112"}}

c9
{"error":{"code":"UnknownError","message":"","innerError":{"date":"2022-02-21T11:54:38","request-id":"ca107748-f71a-4f2c-a492-76ce4057406a","client-request-id":"ca107748-f71a-4f2c-a492-76ce4057406a"}}}
0

Whereas that same call on onedrive personal

2022/02/21 11:56:54 DEBUG : GET /v1.0/drives/71a96798e7b1d253/items/71A96798E7B1D253!724912:/_layouts/default.html: HTTP/1.1
Host: graph.microsoft.com
User-Agent: rclone/v1.58.0-beta.6000.04177102c.fix-5984-vfs-rename-open
Authorization: XXXX
Accept-Encoding: gzip

Works fine

2022/02/21 11:56:54 DEBUG : HTTP RESPONSE (req 0xc0008b6900)
2022/02/21 11:56:54 DEBUG : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: no-store
Client-Request-Id: 0ac91adf-3ae0-46c8-bcf9-b9274f41d3a7
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
Date: Mon, 21 Feb 2022 11:56:54 GMT
Odata-Version: 4.0
Request-Id: 0ac91adf-3ae0-46c8-bcf9-b9274f41d3a7
Strict-Transport-Security: max-age=31536000
Vary: Accept-Encoding
X-Ms-Ags-Diagnostic: {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"3","ScaleUnit":"002","RoleInstance":"LO1PEPF0000060D"}}

626
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#drives('71a96798e7b1d253')/items/$entity","@microsoft.graph.downloadUrl":"https://public.am.files.1drv.com/y4m1eSC4--7KzWdY03mSCFiRhPygmE6-37Q_OU96B-C9HyHieiA9HZ33ajgXn-HDRgfttQ-abJhbpLC9K08P5xcriawxX4H-Ruyu1Xa9XN5k-Qm7U6co8ipx9oshiJQlaNM2LC5Qa7z-ot0ySQ9NjJrcEg7BFI_7I7sgKQDjZD060i0lN18t0daLb3Gm88PyQ8uHepnanEhPGKeosLIeHcQ0kkZEyA2tjVVBsWrHJigPW-xI6t3ZwGE_D-AxGp68CNqT5lNQ3ioc1oiisO-1B4EVk92lPCpXID3F-V5yuSLeDI","createdDateTime":"2022-02-21T11:45:20.927Z","cTag":"aYzo3MUE5Njc5OEU3QjFEMjUzITcyNDkxNS4yNTc","eTag":"aNzFBOTY3OThFN0IxRDI1MyE3MjQ5MTUuMQ","id":"71A96798E7B1D253!724915","lastModifiedDateTime":"2022-02-21T11:45:21.053Z","name":"default.html","size":11,"webUrl":"https://1drv.ms/u/s!AFPSseeYZ6lxrJ8z","reactions":{"commentCount":0},"createdBy":{"application":{"displayName":"rclone","id":"48211038"},"user":{"displayName":"Nick Craig-Wood","id":"71a96798e7b1d253"}},"lastModifiedBy":{"application":{"displayName":"rclone","id":"48211038"},"user":{"displayName":"Nick Craig-Wood","id":"71a96798e7b1d253"}},"parentReference":{"driveId":"71a96798e7b1d253","driveType":"personal","id":"71A96798E7B1D253!724913","name":"_layouts","path":"/drive/root:/onedrive-issue/_layouts"},"file":{"mimeType":"text/html","hashes":{"quickXorHash":"aCgDG9jwBjSUgQ1sc4MCAAAAAAA=","sha1Hash":"60E4CC679A5C273DF21513400CCC98DCF88F3DF1","sha256Hash":"0B9127C34F568B0C41DFA8CE74215BF3E4B66DDD6211563E1F3E0CE2F9AD8194"}},"fileSystemInfo":{"createdDateTime":"2022-02-21T11:45:15Z","lastModifiedDateTime":"2022-02-21T11:45:15Z"}}
0

In the microsoft docs _ is specifically declared a URL save character for the onedrive API

So I think this is a bug on Onedrive Business.

I reported it to Microsoft here: GET on existing file in Onedrive Business fails if directory starts with underscore · Issue #1568 · OneDrive/onedrive-api-docs · GitHub - please subscribe to that issue for updates.