Skip to content

Commit

Permalink
Improve: SUCO: Avoid overwriting backup file unintentionally (address #…
Browse files Browse the repository at this point in the history
…1082 (comment))

Signed-off-by: Isaac Saito <[email protected]>
  • Loading branch information
130s committed Oct 2, 2024
1 parent 3302f30 commit ed80c27
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hut_10sqft/src/hut_10sqft/init_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import shutil
import subprocess
import sys
from datetime import datetime


class HostConf():
Expand Down Expand Up @@ -266,7 +267,7 @@ def copy_a_file(path_source, path_dest, is_symlink=False, overwrite=False, backu

if overwrite:
if backup_suffix:
_backup_file_path = os.path.join(path_dest + backup_suffix)
_backup_file_path = os.path.join(path_dest + backup_suffix + "_" + datetime.today().strftime("%Y%m%d-%H%M%S"))
shutil.copyfile(path_dest, _backup_file_path)
logger.info(f"File '{path_dest} is backed up at '{_backup_file_path}")
os.remove(path_dest)
Expand Down

0 comments on commit ed80c27

Please sign in to comment.