From 37cfb0e63a4bede8f73cd5186b50bf74f4951dc0 Mon Sep 17 00:00:00 2001 From: HGStyle <84084268+HGStyle@users.noreply.github.com> Date: Sun, 30 Jul 2023 19:01:30 +0200 Subject: [PATCH] Update main.py Bugfixes --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 544f87a..7d1d23c 100644 --- a/main.py +++ b/main.py @@ -111,13 +111,13 @@ def ask_for_path(question): def backup_file(file, dir): # Simple function to create a backup - shutil.copyfile(file, os.path.join(dir, file)) + shutil.copyfile(file, os.path.join(dir, os.path.basename(file))) return True def create_backup_dir(path): # Simple function to create backup directory dirname = "backup_" + datetime.datetime.now().strftime('Y%Y-M%m-D%d-h%H') - if dirname not in os.listdir(): + if not os.path.exists(os.path.join(path, dirname)): os.mkdir(os.path.join(path, dirname)) return os.path.join(path, dirname) @@ -211,6 +211,8 @@ def search_savefile(name, path, print_results=False): savefile = input('Input savefile path to add (empty to start fixing) -> ') if not savefile: break + elif not os.path.exists(savefile): + input('Savefile does not exists, check the filepath. Press enter to continue.') elif not os.access(savefile, os.R_OK): # Cannot access to path, gave tips to user based on the OS if systemname == "android": @@ -220,8 +222,6 @@ def search_savefile(name, path, print_results=False): else: print('Access denied, try to relaunch this programm as root/administrator.') input('Press Ctrl+C to exit, press enter to continue.') - elif not os.path.exists(savefile): - input('Savefile does not exists, check the filepath. Press enter to continue.') else: savefiles.append(savefile) clear_screen() @@ -374,7 +374,7 @@ def search_savefile(name, path, print_results=False): success = 0 for savefile in savefiles: try: - result = fix_savefile(savefile) + result = fix_savefile(savefile, systemname) print("Savefile fixed: " + savefile) success += 1 except: