Skip to content

Commit

Permalink
Also clear Update folder (.txt scripts) when clearing scripts
Browse files Browse the repository at this point in the history
 - If this folder is not cleared, and scripts are deleted in the script archive, they will remain in the installation which may cause issues and also cause script re-compile when the game is booted after an update
  • Loading branch information
drojf committed Sep 14, 2024
1 parent cf22e88 commit 798cb36
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions higurashiInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,17 @@ def backupFiles(self):
# The backup (resources.assets.backup) will be deleted on a successful install
self.tryBackupFile('resources.assets')

def clearCompiledScripts(self):
compiledScriptsPattern = path.join(self.assetsDir, "CompiledUpdateScripts/*.mg")
def clearScriptsAndCompiledScripts(self):
for globPattern in ["CompiledUpdateScripts/*.mg", "Update/*.txt"]:
compiledScriptsPattern = path.join(self.assetsDir, globPattern)

print("Attempting to clear compiled scripts")
try:
for mg in glob.glob(compiledScriptsPattern):
forceRemove(mg)
except Exception:
print('WARNING: Failed to clean up the [{}] compiledScripts'.format(compiledScriptsPattern))
traceback.print_exc()
print("Attempting to clear compiled scripts")
try:
for mg in glob.glob(compiledScriptsPattern):
forceRemove(mg)
except Exception:
print('WARNING: Failed to clean up the [{}] compiledScripts'.format(compiledScriptsPattern))
traceback.print_exc()

def cleanOld(self):
"""
Expand All @@ -243,7 +244,7 @@ def cleanOld(self):
oldCGAlt = path.join(self.assetsDir, "CGAlt")

if self.clearScripts:
self.clearCompiledScripts()
self.clearScriptsAndCompiledScripts()

# Only delete the oldCG and oldCGAlt folders on a full update, as the CG pack won't always be extracted
if self.fileVersionManager.fullUpdateRequired():
Expand Down

0 comments on commit 798cb36

Please sign in to comment.