@@ -2011,8 +2011,35 @@ async function applyPatching(
2011
2011
}
2012
2012
// need this to cover 100% of abort cases
2013
2013
if ( aborted ) {
2014
- await safeRemoveDirectory ( datastoreDir , {
2015
- sizeThresholdMB : blockSize * totalBlocks
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
+ }
2016
2043
} )
2017
2044
return { status : 'abort' }
2018
2045
}
@@ -2028,9 +2055,27 @@ async function applyPatching(
2028
2055
} )
2029
2056
2030
2057
logInfo ( `Patching ${ appName } completed` , LogPrefix . HyperPlay )
2031
- await safeRemoveDirectory ( datastoreDir , {
2032
- sizeThresholdMB : blockSize * totalBlocks
2033
- } )
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
+ } )
2073
+
2074
+ logWarning (
2075
+ `Patching succeeded but cleanup failed: ${ cleanupError } ` ,
2076
+ LogPrefix . HyperPlay
2077
+ )
2078
+ }
2034
2079
return { status : 'done' }
2035
2080
} catch ( error ) {
2036
2081
if ( error instanceof PatchingError ) {
@@ -2070,7 +2115,23 @@ async function applyPatching(
2070
2115
2071
2116
// errors can be thrown before datastore dir created. rmSync on nonexistent dir blocks indefinitely
2072
2117
if ( existsSync ( datastoreDir ) ) {
2073
- await safeRemoveDirectory ( 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
+ }
2074
2135
}
2075
2136
2076
2137
return { status : 'error' , error : `Error while patching ${ error } ` }
0 commit comments