mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2024-11-16 06:57:11 +01:00
Add support for symlinked database files (#3129)
This commit is contained in:
parent
8dab58f2b4
commit
e95f6811f7
@ -5,8 +5,18 @@ let dbPath = null
|
||||
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 userDataPath = app.getPath('userData') // This is based on the user's OS
|
||||
dbPath = (dbName) => join(userDataPath, `${dbName}.db`)
|
||||
dbPath = (dbName) => {
|
||||
let path = join(userDataPath, `${dbName}.db`)
|
||||
|
||||
if (existsSync(path) && statSync(path).isSymbolicLink) {
|
||||
path = realpathSync(path)
|
||||
}
|
||||
|
||||
return path
|
||||
}
|
||||
} else {
|
||||
dbPath = (dbName) => `${dbName}.db`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user