CONFIGFILE: Added BACKUP and RESTART to SAVE_CONFIG

https://github.com/Klipper3d/klipper/pull/4515/files
This commit is contained in:
Nikolay Kopitonenko 2024-02-13 15:44:20 +03:00
parent a77d07907f
commit cfe89d7c63
1 changed files with 4 additions and 2 deletions

View File

@ -416,11 +416,13 @@ class PrinterConfig:
f = open(temp_name, 'w') f = open(temp_name, 'w')
f.write(data) f.write(data)
f.close() f.close()
os.rename(cfgname, backup_name) if gcmd.get_int('BACKUP', 1):
os.rename(cfgname, backup_name)
os.rename(temp_name, cfgname) os.rename(temp_name, cfgname)
except: except:
msg = "Unable to write config file during SAVE_CONFIG" msg = "Unable to write config file during SAVE_CONFIG"
logging.exception(msg) logging.exception(msg)
raise gcode.error(msg) raise gcode.error(msg)
# Request a restart # Request a restart
gcode.request_restart('restart') if gcmd.get_int('RESTART', 1):
gcode.request_restart('restart')