Reduced likelihood of mmm crash

This commit is contained in:
Timothy GFO 2023-11-12 14:35:22 -04:00
parent 315a036904
commit 6a42701161

View file

@ -71,6 +71,18 @@ def check_folder_structure(megamaker_folder, og_music=False):
else: else:
return False return False
def copy_music_to_ogmusic(path):
path = os.path.abspath(path)
original_filepaths = check_folder_structure(path)
if original_filepaths:
if not filecmp.cmp(os.path.join(path,"Music","MM1","Cutman.nsf"), os.path.join(path, "Music", "MM1", "Oilman.nsf"), shallow=False):
shutil.copytree(os.path.join(path, "Music"), os.path.join(path, "original_music"), dirs_exist_ok=True)
if not os.path.exists(os.path.join(path, "Music")):
os.makedirs(os.path.join(path, "Music"))
else:
print("Cutman.nsf and Oilman.nsf match in Music folder.")
return False
#this needs to check if original_music exists, and if it does restore_ogmusic before moving to og music. #this needs to check if original_music exists, and if it does restore_ogmusic before moving to og music.
def move_music_to_ogmusic(path): def move_music_to_ogmusic(path):
path = os.path.abspath(path) path = os.path.abspath(path)
@ -128,7 +140,8 @@ def nsf_changer (nsf_path, megamaker_folder):
restore_ogmusic(megamaker_folder) restore_ogmusic(megamaker_folder)
shutil.copy(nsf_path, os.path.join(megamaker_folder, os.path.basename(nsf_path))) shutil.copy(nsf_path, os.path.join(megamaker_folder, os.path.basename(nsf_path)))
nsf_path = os.path.join(megamaker_folder, os.path.basename(nsf_path)) nsf_path = os.path.join(megamaker_folder, os.path.basename(nsf_path))
move_music_to_ogmusic(megamaker_folder) #move_music_to_ogmusic(megamaker_folder)
copy_music_to_ogmusic(megamaker_folder)
recreate_structure(nsf_path, original_path) recreate_structure(nsf_path, original_path)
print("nsf changer returning true") print("nsf changer returning true")
return True return True