Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/stage-tamagotchi/electron-builder.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default {
deleteAppDataOnUninstall: true,
oneClick: false,
allowToChangeInstallationDirectory: true,
runAfterFinish: true,
},
mac: {
entitlementsInherit: 'build/entitlements.mac.plist',
Expand Down
9 changes: 8 additions & 1 deletion apps/stage-tamagotchi/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,19 @@ async function handleAppExit() {
skipFileLogging = true
await logIfError('flush file logs', () => fileLogger.close()) // Ensure all logs are flushed

app.exit(exitedNormally ? 0 : 1)
if (!exitedNormally) {
app.exit(1)
} else {
app.quit()
}
}

process.on('SIGINT', () => handleAppExit())

app.on('before-quit', (event) => {
if (appExiting)
return

event.preventDefault()
handleAppExit()
})
Comment on lines 335 to 341
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ function getCacheRoot() {
}

function getLegacyCacheRoot() {
return getCacheRoot()
switch (process.platform) {
case 'win32':
return process.env.LOCALAPPDATA || join(process.env.USERPROFILE || '', 'AppData', 'Local')
case 'darwin':
return join(process.env.HOME || '', 'Library', 'Caches')
default:
return process.env.XDG_CACHE_HOME || join(process.env.HOME || '', '.cache')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use absolute fallback paths for legacy cache root

When the expected environment variables are missing, this fallback builds relative paths (for example join('', '.cache') or join('', 'Library', 'Caches')). cleanupStaleUpdateFiles() later calls rm(..., { recursive: true, force: true }) on the derived updater cache directory, so in those environments it can delete a directory relative to the current working directory instead of the user cache location, and it will also miss the actual legacy cache directory. Use an absolute fallback such as app.getPath('home')/os.homedir() before appending cache segments.

Useful? React with 👍 / 👎.

}
Comment on lines +50 to +57
}

const UPDATER_DEBUG_CACHE_DIR = join(getCacheRoot(), 'stage-tamagotchi-updater')
Expand Down
Loading