Pārlūkot izejas kodu

put temporary data file in the same director as the data file itself

This should make shutil.move use rename, which is atomic, avoiding
losing data when interweaving writes happen.

This will close joelthelion/autojump#358.
pull/476/merge
lilydjwg pirms 9 gadiem
revīziju iesūtīja William Ting
vecāks
revīzija
8fffbad95a
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. +3
    -2
      bin/autojump_data.py

+ 3
- 2
bin/autojump_data.py Parādīt failu

@ -120,11 +120,12 @@ def migrate_osx_xdg_data(config):
def save(config, data):
"""Save data and create backup, creating a new data file if necessary."""
create_dir(os.path.dirname(config['data_path']))
data_dir = os.path.dirname(config['data_path'])
create_dir(data_dir)
# atomically save by writing to temporary file and moving to destination
try:
temp = NamedTemporaryFile(delete=False)
temp = NamedTemporaryFile(delete=False, dir=data_dir)
# Windows cannot reuse the same open file name
temp.close()

Notiek ielāde…
Atcelt
Saglabāt