I've been tasked with migrating a live SharePoint document library to another document library. As we want to keep downtime to a minimum, I've synchronised the two document libraries to my PC using OneDrive and I'm using robocopy to mirror between the two local copies. Pretty routine stuff for network shares.
However, I noticed that when I re-ran the mirror command, robocopy copied a lot of files again. I could expect a handful of changes but not thousands. Also, robocopy was flagging the files as "changed" which IMO is a very unusual copy reason for robocopy - this means the timestamp is unchanged but the size of the file has changed...
Further diagnosis revealed that it was only Office documents, e.g. pptx than were being copied again. Other file types like PDF and graphic files copied once and not again.
I finally tracked it down to this observation:
- Copy a file to OneDrive using (say) cmd.exe copy
- Look at file size immediately in OneDrive and it matches the original size
- Wait until OneDrive synchronises it and check file size again
The size has changed. Here is a PowerShell script that copies a file, gets the size immediately, waits 15 seconds (for sync) and get the size again.
$SourceFile = "S:\Temp\Helios\Library\Example.pptx"
$TargetFile = "C:\Users\rob.nicholson\Helios Medical Communications\Library - Documents (unused)\Example.pptx"
Copy-Item $SourceFile $TargetFile
$Length1 = (Get-Item $SourceFile).Length
$Length2 = (Get-Item $TargetFile).Length
Start-Sleep 15
$Length3 = (Get-Item $TargetFile).Length
Write-Host "Orignal size: $Length1"
Write-Host "After copy size: $Length2"
Write-Host "After sync size: $Length3"
This is the output:
Source size: 1996810
After copy size: 1996810
After sync size: 1997141
Can anyone explain why the file size is changing? Another observation is that OneDrive will say "Uploading" and then it immediately says "Downloading" - which is when the file size changes.
Makes using sync tools rather difficult with OneDrive. Needless to say, Google Drive or Dropbox doesn't have the same issue.
One final note: OneDrive "On-demand" is enabled.