Bug in disk space allocation when copying several files from a MTP device using Explorer (Windows 8)

I don't know if it's the right place to report bugs for Windows 8, but since Connect doesn't seem to accept Windows bugs, I thought I'd do it here...

When you copy several files from a MTP device (e.g. a smartphone) using Windows Explorer, the copy allocates X bytes for each copied file, where X is the total size of all files to copy ; the file is then truncated to its "real" size before it's closed. This can lead to using up to twice the necessary space on disk (temporarily of course), which could make the copy fail even though there is actually enough space (e.g. if you try to copy 1GB of data when there is 1.5 GB of available space).

Here's an example of this scenario, with the corresponding Process Monitor event log (open with Process Monitor):
  • Copy 39 photos and videos from an iPhone to a local folder
  • The total size of these files is 125 MB (131 437 156 B)
  • The first source file, IMG_0364.MOV, has a size of 104 MB (109 664 278 B)
  • The destination file is first created with a length of 0 (event with sequence number 12 in the event log)
  • Its length is then extended to 131 437 156 B (event 14), which is the total size of all 39 copied files
  • Data is copied to the file normally (events 18 to 1039)
  • The file length is then truncated to the real size (109 664 278 B) (event 1040)

The same thing happens to each of the 39 copied files: regardless of the actual size of the source file, the destination file has its length extended to the total size of all files.

I noticed it only because it caused a bug in the application I'm developing ; it's probably not a big issue for most users, but still, it really looks like a bug in Windows Explorer. I reproduced the same issue with two different phones (an iPhone 4 and a Nokia Lumia 920), but not with a USB key, which makes me think the problem is specific to MTP devices.

Question Info

Last updated March 24, 2018 Views 86 Applies to: