Skip the exists check for the databases, as stat does it anyway (#3272)

This commit is contained in:
absidue 2023-03-07 07:07:18 +01:00 committed by GitHub
parent da0c06902b
commit 3225b3759a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -6,12 +6,13 @@ if (process.env.IS_ELECTRON_MAIN) {
const { app } = require('electron')
const { join } = require('path')
// this code only runs in the electron main process, so hopefully using sync fs code here should be fine 😬
const { existsSync, statSync, realpathSync } = require('fs')
const { statSync, realpathSync } = require('fs')
const userDataPath = app.getPath('userData') // This is based on the user's OS
dbPath = (dbName) => {
let path = join(userDataPath, `${dbName}.db`)
if (existsSync(path) && statSync(path).isSymbolicLink) {
// returns undefined if the path doesn't exist
if (statSync(path, { throwIfNoEntry: false })?.isSymbolicLink) {
path = realpathSync(path)
}