When I test this on my machine, the last two processes to read a chunk will occasionally both attempt to write the combined file.
Cakephp can use locking to ensure no more than one process writes to a file at a time, however it does not guarantee that only one process writes to a file at all. For this, we need to open the file with the O_EXCL flag (x in PHP).
This pull request ensures only one process will write to destFile.
When I test this on my machine, the last two processes to read a chunk will occasionally both attempt to write the combined file.
Cakephp can use locking to ensure no more than one process writes to a file at a time, however it does not guarantee that only one process writes to a file at all. For this, we need to open the file with the
O_EXCL
flag (x
in PHP).This pull request ensures only one process will write to
destFile
.