@@ -30,8 +30,8 @@ def forceRmTree(path):
30
30
shutil .rmtree (path , onerror = on_rm_error )
31
31
32
32
class Installer :
33
- def __init__ (self , fullInstallConfiguration ):
34
- # type: (gameScanner.FullInstallConfiguration) -> None
33
+ def __init__ (self , fullInstallConfiguration , extractDirectlyToGameDirectory ):
34
+ # type: (gameScanner.FullInstallConfiguration, bool ) -> None
35
35
36
36
"""
37
37
Installer Init
@@ -64,9 +64,8 @@ def __init__(self, fullInstallConfiguration):
64
64
if path .exists (possibleSteamPath ):
65
65
self .isSteam = True
66
66
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
68
67
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" )
70
69
71
70
self .downloaderAndExtractor = common .DownloaderAndExtractor (modFileList = self .info .buildFileListSorted (datadir = self .dataDirectory ),
72
71
downloadTempDir = self .downloadDir ,
@@ -179,7 +178,7 @@ def _moveFileIntoPlace(self, fromPath, toPath):
179
178
forceRemove (toPath )
180
179
shutil .move (fromPath , toPath )
181
180
182
- def cleanup (self ):
181
+ def cleanup (self , cleanExtractionDirectory ):
183
182
"""
184
183
General cleanup and other post-install things
185
184
@@ -188,7 +187,8 @@ def cleanup(self):
188
187
"""
189
188
try :
190
189
forceRmTree (self .downloadDir )
191
- forceRmTree (self .extractDir )
190
+ if cleanExtractionDirectory :
191
+ forceRmTree (self .extractDir )
192
192
except OSError :
193
193
pass
194
194
@@ -209,15 +209,29 @@ def cleanup(self):
209
209
210
210
def main (fullInstallConfiguration ):
211
211
# 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
+
223
237
commandLineParser .printSeventhModStatusUpdate (100 , "Install Completed!" )
0 commit comments