`move_file` may cause data loss
Created by: lilydjwg
Days ago I found autojump forgot some of my frequent paths. After reading the code, I think this may be caused by that move_file
isn't really atomic.
My system is Arch Linux and autojump version is v22.2.4.
On saving paths, autojump creates a temporary file, which by default, is in /tmp. /tmp isn't on the same filesystem with my autojump data file, so when move_file
calls shutil.move
, what really happens is copy and then delete. It's not atomic. Running with strace I can see there are multiple write
calls to the data file. When multiple processes hit here, interweaving writes will result in a partial loss.
I suggest you use a temporary file in the same directory as the data file. I can provide a patch if you accept doing it this way.