Minecraft client: skip deleting and recopying an apmc file that is already in APData
This commit is contained in:
parent
ce6cdcaf92
commit
81da0d2ba4
|
@ -61,13 +61,18 @@ def replace_apmc_files(forge_dir, apmc_file):
|
||||||
if apmc_file is None:
|
if apmc_file is None:
|
||||||
return
|
return
|
||||||
apdata_dir = os.path.join(forge_dir, 'APData')
|
apdata_dir = os.path.join(forge_dir, 'APData')
|
||||||
|
copy_apmc = True
|
||||||
if not os.path.isdir(apdata_dir):
|
if not os.path.isdir(apdata_dir):
|
||||||
os.mkdir(apdata_dir)
|
os.mkdir(apdata_dir)
|
||||||
print(f"Created APData folder in {forge_dir}")
|
print(f"Created APData folder in {forge_dir}")
|
||||||
for entry in os.scandir(apdata_dir):
|
for entry in os.scandir(apdata_dir):
|
||||||
if ".apmc" in entry.name and entry.is_file():
|
if entry.name.endswith(".apmc") and entry.is_file():
|
||||||
|
if not os.path.samefile(apmc_file, entry.path):
|
||||||
os.remove(entry.path)
|
os.remove(entry.path)
|
||||||
print(f"Removed {entry.name} in {apdata_dir}")
|
print(f"Removed {entry.name} in {apdata_dir}")
|
||||||
|
else: # apmc already in apdata
|
||||||
|
copy_apmc = False
|
||||||
|
if copy_apmc:
|
||||||
copyfile(apmc_file, os.path.join(apdata_dir, os.path.basename(apmc_file)))
|
copyfile(apmc_file, os.path.join(apdata_dir, os.path.basename(apmc_file)))
|
||||||
print(f"Copied {os.path.basename(apmc_file)} to {apdata_dir}")
|
print(f"Copied {os.path.basename(apmc_file)} to {apdata_dir}")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue