
15 Apr
2021
15 Apr
'21
5:27 a.m.
That would work but may not be the most efficient in all cases. On many
systems, /tmp is a tmpfs, which being memory-backed is more efficient than
a file on a physical disk or network, so writing to /tmp has performance
advantages.
On Thu, Apr 15, 2021 at 4:23 PM Daniel Trstenjak
Hi Josh,
the fastest and safest way is to create the temporary file in the directory of the final location and then move the file to its final name.
This way you ensure that the temporary file is always on the same device or partition as the final file and therefore a move is always possible.
And it's the safest, because a move is an atomic operation - which copy isn't - and therefore other processes will never see a partially updated file.
Greetings, Daniel