When you deliver the created archive/zip file via private file system, the downloaded file will be corrupted because a wrong filesize got saved into the file_managed table.
I added clearstatcache(); to clear the cache of the filesize() function.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | clear_filesize_cache-2743999-2.patch | 590 bytes | haggins |
Comments
Comment #2
haggins commentedComment #3
haggins commentedComment #4
hobbsgoblin commentedThe patch worked for me.
Comment #5
haggins commentedSetting to RTBC thanks to #4
Comment #6
joelpittetHow is the wrong size getting into the stat cache in the first place?
Can you add the steps needed to reproduce this?
Comment #7
haggins commentedI'm no longer employed at the company which worked on that particular project. So I can just try to recall what happened:
From the documentation of clearstatcache (https://secure.php.net/manual/en/function.clearstatcache.php):
I guess this happens if you archive enough files at once so that more than one batch iteration is necessary. Then we may get the too small size cached by the following lines:
Comment #8
joelpittetThanks for the explaination @haggins. This may be an issue with the public file system as well?
Comment #9
chris burge commentedI've been having issues with VBO-generated archives being corrupted prior to download. The patch from #2 corrects this issue.
Comment #10
haggins commented@joelpitt, no there are no problems when you use a public file system as the file will be downloaded directly, ignoring the contents of the file_managed table. The issue just appears on private file systems because Drupal reads the file length from the database and delivers only that amount of bytes to the client.
Comment #12
joelpittetI added a bit more documentation around the fix and committed it to -dev. Thanks for explaining the issue further.