@@ -65,8 +65,7 @@ import {
65
65
handleArchAndPlatform ,
66
66
handlePlatformReversed ,
67
67
runModPatcher ,
68
- sanitizeVersion ,
69
- safeRemoveDirectory
68
+ sanitizeVersion
70
69
} from './utils'
71
70
import { getSettings as getSettingsSideload } from 'backend/storeManagers/sideload/games'
72
71
import {
@@ -424,11 +423,11 @@ const findExecutables = async (folderPath: string): Promise<string[]> => {
424
423
return executables
425
424
}
426
425
427
- export async function cleanUpDownload ( appName : string , directory : string ) {
426
+ export function cleanUpDownload ( appName : string , directory : string ) {
428
427
inProgressDownloadsMap . delete ( appName )
429
428
inProgressExtractionsMap . delete ( appName )
430
429
deleteAbortController ( appName )
431
- await safeRemoveDirectory ( directory )
430
+ rmSync ( directory , { recursive : true , force : true } )
432
431
}
433
432
434
433
function getDownloadUrl ( platformInfo : PlatformConfig , appName : string ) {
@@ -524,9 +523,9 @@ async function downloadGame(
524
523
res ( )
525
524
}
526
525
527
- async function onCancel ( ) {
526
+ function onCancel ( ) {
528
527
try {
529
- await cleanUpDownload ( appName , directory )
528
+ cleanUpDownload ( appName , directory )
530
529
} catch ( err ) {
531
530
rej ( err )
532
531
}
@@ -1182,7 +1181,7 @@ export async function extract(
1182
1181
body : `Installed`
1183
1182
} )
1184
1183
1185
- await cleanUpDownload ( appName , directory )
1184
+ cleanUpDownload ( appName , directory )
1186
1185
1187
1186
sendFrontendMessage ( 'refreshLibrary' , 'hyperplay' )
1188
1187
@@ -1191,21 +1190,21 @@ export async function extract(
1191
1190
} )
1192
1191
}
1193
1192
)
1194
- extractService . once ( 'error' , async ( error : Error ) => {
1193
+ extractService . once ( 'error' , ( error : Error ) => {
1195
1194
logError ( `Extracting Error ${ error . message } ` , LogPrefix . HyperPlay )
1196
1195
1197
1196
cancelQueueExtraction ( )
1198
1197
callAbortController ( appName )
1199
1198
1200
- await cleanUpDownload ( appName , directory )
1199
+ cleanUpDownload ( appName , directory )
1201
1200
1202
1201
sendFrontendMessage ( 'refreshLibrary' , 'hyperplay' )
1203
1202
1204
1203
resolve ( {
1205
1204
status : 'error'
1206
1205
} )
1207
1206
} )
1208
- extractService . once ( 'canceled' , async ( ) => {
1207
+ extractService . once ( 'canceled' , ( ) => {
1209
1208
logInfo (
1210
1209
`Canceled Extracting: Cancellation completed on ${ appName } - Destination ${ destinationPath } ` ,
1211
1210
LogPrefix . HyperPlay
@@ -1243,7 +1242,7 @@ export async function extract(
1243
1242
body : 'Installation Stopped'
1244
1243
} )
1245
1244
1246
- await cleanUpDownload ( appName , directory )
1245
+ cleanUpDownload ( appName , directory )
1247
1246
1248
1247
sendFrontendMessage ( 'refreshLibrary' , 'hyperplay' )
1249
1248
@@ -1915,18 +1914,13 @@ async function applyPatching(
1915
1914
1916
1915
if ( signal . aborted ) {
1917
1916
logInfo ( `Patching ${ appName } aborted` , LogPrefix . HyperPlay )
1918
- await safeRemoveDirectory ( datastoreDir , {
1919
- sizeThresholdMB : blockSize * totalBlocks
1920
- } )
1921
- aborted = true
1917
+ rmSync ( datastoreDir , { recursive : true } )
1922
1918
return { status : 'abort' }
1923
1919
}
1924
1920
1925
- signal . onabort = async ( ) => {
1921
+ signal . onabort = ( ) => {
1926
1922
aborted = true
1927
- await safeRemoveDirectory ( datastoreDir , {
1928
- sizeThresholdMB : blockSize * totalBlocks
1929
- } )
1923
+ rmSync ( datastoreDir , { recursive : true } )
1930
1924
return { status : 'abort' }
1931
1925
}
1932
1926
@@ -2011,36 +2005,7 @@ async function applyPatching(
2011
2005
}
2012
2006
// need this to cover 100% of abort cases
2013
2007
if ( aborted ) {
2014
- try {
2015
- await safeRemoveDirectory ( datastoreDir , {
2016
- sizeThresholdMB : blockSize * totalBlocks
2017
- } )
2018
- } catch ( cleanupError ) {
2019
- trackEvent ( {
2020
- event : 'Patching Cleanup Failed' ,
2021
- properties : {
2022
- error : `${ cleanupError } ` ,
2023
- game_name : gameInfo . app_name ,
2024
- game_title : gameInfo . title ,
2025
- platform : getPlatformName ( platform ) ,
2026
- platform_arch : platform
2027
- }
2028
- } )
2029
-
2030
- logWarning (
2031
- `Patching aborted and cleanup failed: ${ cleanupError } ` ,
2032
- LogPrefix . HyperPlay
2033
- )
2034
- }
2035
- trackEvent ( {
2036
- event : 'Patching Aborted' ,
2037
- properties : {
2038
- game_name : gameInfo . app_name ,
2039
- game_title : gameInfo . title ,
2040
- platform : getPlatformName ( platform ) ,
2041
- platform_arch : platform
2042
- }
2043
- } )
2008
+ rmSync ( datastoreDir , { recursive : true } )
2044
2009
return { status : 'abort' }
2045
2010
}
2046
2011
@@ -2055,27 +2020,8 @@ async function applyPatching(
2055
2020
} )
2056
2021
2057
2022
logInfo ( `Patching ${ appName } completed` , LogPrefix . HyperPlay )
2058
- try {
2059
- await safeRemoveDirectory ( datastoreDir , {
2060
- sizeThresholdMB : blockSize * totalBlocks
2061
- } )
2062
- } catch ( cleanupError ) {
2063
- trackEvent ( {
2064
- event : 'Patching Cleanup Failed' ,
2065
- properties : {
2066
- error : `${ cleanupError } ` ,
2067
- game_name : gameInfo . app_name ,
2068
- game_title : gameInfo . title ,
2069
- platform : getPlatformName ( platform ) ,
2070
- platform_arch : platform
2071
- }
2072
- } )
2023
+ rmSync ( datastoreDir , { recursive : true } )
2073
2024
2074
- logWarning (
2075
- `Patching succeeded but cleanup failed: ${ cleanupError } ` ,
2076
- LogPrefix . HyperPlay
2077
- )
2078
- }
2079
2025
return { status : 'done' }
2080
2026
} catch ( error ) {
2081
2027
if ( error instanceof PatchingError ) {
@@ -2115,23 +2061,7 @@ async function applyPatching(
2115
2061
2116
2062
// errors can be thrown before datastore dir created. rmSync on nonexistent dir blocks indefinitely
2117
2063
if ( existsSync ( datastoreDir ) ) {
2118
- try {
2119
- await safeRemoveDirectory ( datastoreDir )
2120
- } catch ( cleanupError ) {
2121
- trackEvent ( {
2122
- event : 'Patching Cleanup Failed' ,
2123
- properties : {
2124
- error : `${ cleanupError } ` ,
2125
- game_name : gameInfo . app_name ,
2126
- game_title : gameInfo . title
2127
- }
2128
- } )
2129
-
2130
- logWarning (
2131
- `Patching failed and cleanup failed: ${ cleanupError } ` ,
2132
- LogPrefix . HyperPlay
2133
- )
2134
- }
2064
+ rmSync ( datastoreDir , { recursive : true } )
2135
2065
}
2136
2066
2137
2067
return { status : 'error' , error : `Error while patching ${ error } ` }
0 commit comments