Skip to content

Commit e80431f

Browse files
committed
On Windows, extract archives directly to game folder
1 parent 7b373a9 commit e80431f

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

higurashiInstaller.py

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def forceRmTree(path):
3030
shutil.rmtree(path, onerror=on_rm_error)
3131

3232
class Installer:
33-
def __init__(self, fullInstallConfiguration):
34-
# type: (gameScanner.FullInstallConfiguration) -> None
33+
def __init__(self, fullInstallConfiguration, extractDirectlyToGameDirectory):
34+
# type: (gameScanner.FullInstallConfiguration, bool) -> None
3535

3636
"""
3737
Installer Init
@@ -64,9 +64,8 @@ def __init__(self, fullInstallConfiguration):
6464
if path.exists(possibleSteamPath):
6565
self.isSteam = True
6666

67-
#TODO: DROJF - Not sure if should use 'name' or 'target'. I have set the json such that 'name' is the descriptive name, 'target' is the target game to install to
6867
self.downloadDir = self.info.subModConfig.modName + " Downloads"
69-
self.extractDir = self.info.subModConfig.modName + " Extraction"
68+
self.extractDir = self.directory if extractDirectlyToGameDirectory else (self.info.subModConfig.modName + " Extraction")
7069

7170
self.downloaderAndExtractor = common.DownloaderAndExtractor(modFileList=self.info.buildFileListSorted(datadir=self.dataDirectory),
7271
downloadTempDir=self.downloadDir,
@@ -179,7 +178,7 @@ def _moveFileIntoPlace(self, fromPath, toPath):
179178
forceRemove(toPath)
180179
shutil.move(fromPath, toPath)
181180

182-
def cleanup(self):
181+
def cleanup(self, cleanExtractionDirectory):
183182
"""
184183
General cleanup and other post-install things
185184
@@ -188,7 +187,8 @@ def cleanup(self):
188187
"""
189188
try:
190189
forceRmTree(self.downloadDir)
191-
forceRmTree(self.extractDir)
190+
if cleanExtractionDirectory:
191+
forceRmTree(self.extractDir)
192192
except OSError:
193193
pass
194194

@@ -209,15 +209,29 @@ def cleanup(self):
209209

210210
def main(fullInstallConfiguration):
211211
# type: (gameScanner.FullInstallConfiguration) -> None
212-
installer = Installer(fullInstallConfiguration)
213-
print("Downloading...")
214-
installer.download()
215-
print("Extracting...")
216-
installer.extractFiles()
217-
commandLineParser.printSeventhModStatusUpdate(85, "Moving files into place...")
218-
installer.backupUI()
219-
installer.cleanOld()
220-
installer.moveFilesIntoPlace()
221-
commandLineParser.printSeventhModStatusUpdate(97, "Cleaning up...")
222-
installer.cleanup()
212+
213+
# On Windows, extract directly to the game directory to avoid path-length issues and speed up install
214+
if common.Globals.IS_WINDOWS:
215+
installer = Installer(fullInstallConfiguration, extractDirectlyToGameDirectory=True)
216+
print("Downloading...")
217+
installer.download()
218+
installer.backupUI()
219+
installer.cleanOld()
220+
print("Extracting...")
221+
installer.extractFiles()
222+
commandLineParser.printSeventhModStatusUpdate(97, "Cleaning up...")
223+
installer.cleanup(cleanExtractionDirectory=False)
224+
else:
225+
installer = Installer(fullInstallConfiguration, extractDirectlyToGameDirectory=False)
226+
print("Downloading...")
227+
installer.download()
228+
print("Extracting...")
229+
installer.extractFiles()
230+
commandLineParser.printSeventhModStatusUpdate(85, "Moving files into place...")
231+
installer.backupUI()
232+
installer.cleanOld()
233+
installer.moveFilesIntoPlace()
234+
commandLineParser.printSeventhModStatusUpdate(97, "Cleaning up...")
235+
installer.cleanup(cleanExtractionDirectory=True)
236+
223237
commandLineParser.printSeventhModStatusUpdate(100, "Install Completed!")

0 commit comments

Comments
 (0)