fix: possible interruption caused by failure to read cache file

This commit is contained in:
mio 2023-05-02 09:07:37 +08:00
parent f95470504d
commit 677ab3750d
2 changed files with 5 additions and 2 deletions

@ -1,6 +1,6 @@
{
"name": "star-rail-warp-export",
"version": "0.0.6",
"version": "0.0.7",
"main": "./dist/electron/main/main.js",
"author": "biuuu <https://github.com/biuuu>",
"license": "MIT",

@ -117,7 +117,10 @@ const readLog = async () => {
const logText = await fs.readFile(logpath, 'utf8')
const gamePathMch = logText.match(/\w:\/.*?\/StarRail_Data\//)
if (gamePathMch) {
const cacheText = await fs.readFile(path.join(gamePathMch[0], '/webCaches/Cache/Cache_Data/data_2'), 'utf8')
let cacheText = ''
try {
cacheText = await fs.readFile(path.join(gamePathMch[0], '/webCaches/Cache/Cache_Data/data_2'), 'utf8')
} catch (e) {}
const urlMch = cacheText.match(/https.+?&auth_appid=webview_gacha&.+?authkey=.+?&game_biz=hkrpg_.+?&plat_type=pc/g)
if (urlMch) {
cacheFolder = path.join(gamePathMch[0], '/webCaches/Cache/')