fix: copying file using transferTo sometimes fails.
#1862
Merged
transferTo sometimes fails.
#1862