Skip to content

Commit

Permalink
Fixed issue with backup_files changes not working with other functions
Browse files Browse the repository at this point in the history
  • Loading branch information
theflyingzamboni committed Aug 29, 2021
1 parent e772bea commit 4db8cee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 9 additions & 10 deletions disc_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def _def_path(file_system_object):
file_system_object)


def backup_file(disc_dict, restore_from_backup=False):
def backup_file(input_file, restore_from_backup=False):
"""
Creates/restores disc image backup.
Expand All @@ -67,15 +67,14 @@ def backup_file(disc_dict, restore_from_backup=False):

# DO NOT DELETE .orig file if .bin file has been modified

for disc, disc_val in disc_dict.items():
input_backup = ''.join((disc_val[0], '.orig'))

if not os.path.exists(input_backup):
print(f'Backing up {disc_val[0]}')
shutil.copy(disc_val[0], input_backup)
elif restore_from_backup:
print(f'Restoring {disc_val[0]} from backup')
shutil.copy(input_backup, disc_val[0])
input_backup = ''.join((input_file, '.orig'))

if not os.path.exists(input_backup):
print(f'Backing up {input_file}')
shutil.copy(input_file, input_backup)
elif restore_from_backup:
print(f'Restoring {input_file} from backup')
shutil.copy(input_backup, input_file)


def cdpatch(disc_dict, mode='-x'):
Expand Down
3 changes: 2 additions & 1 deletion lodmods.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ def parse_arguments():
disc_dict = _build_disc_dict(config_dict, args.version, args.disc,
scripts_dir, game_files_dir)

args.file_backup(disc_dict, args.restore_from_backup)
for disc, disc_val in disc_dict.items():
args.file_backup(disc_val[0], args.restore_from_backup)
elif args.func == 'cdpatch':
# TODO: Need to consider the case of all discs, and what this tool should be used for
if args.disc[0] == '*':
Expand Down

0 comments on commit 4db8cee

Please sign in to comment.