Skip to content

Commit c1ae9a9

Browse files
committed
Change finding out whether the application is a portable instance
This fixes issue #58 If the application doesn't run from a usual installation path, it is assumed that it is a portable instance. No extra steps during the installation process needed! Following environment variables are used: - ProgramFiles: usual global path for 64 bits applications - LOCALAPPDATA: usual user local path for applications
1 parent c675f7f commit c1ae9a9

File tree

4 files changed

+6
-20
lines changed

4 files changed

+6
-20
lines changed

app/main.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const storage = require("./lib/storageMain")
2525
const toc = require("./lib/tocMain")
2626
const zoom = require("./lib/zoomMain")
2727

28-
const DATA_DIR_FILE = ".datadir"
29-
const USER_DATA_PLACEHOLDER = "MDVIEW_USER_DATA"
30-
3128
const MIN_WINDOW_WIDTH = 200 // Pixels
3229
const MIN_WINDOW_HEIGHT = 50 // Pixels
3330
const UPDATE_INTERVAL = 1000 // ms
@@ -601,14 +598,12 @@ if (cli.isDevelopment()) {
601598
"userData",
602599
path.join(path.resolve(args.slice(1).find(arg => !arg.startsWith("-"))), ".data"),
603600
)
604-
} else if (process.platform === "win32") {
605-
const dataPath = fs.readFileSync(path.join(appDir, DATA_DIR_FILE), { encoding: "utf-8" }).trim()
606-
if (dataPath !== USER_DATA_PLACEHOLDER) {
607-
electron.app.setPath(
608-
"userData",
609-
path.isAbsolute(dataPath) ? dataPath : path.join(appDir, ".data"),
610-
)
611-
}
601+
} else if (
602+
process.platform === "win32" &&
603+
!appDir.startsWith(process.env.ProgramFiles) &&
604+
!appDir.startsWith(process.env.LOCALAPPDATA)
605+
) {
606+
electron.app.setPath("userData", path.join(appDir, ".data"))
612607
}
613608

614609
// If set, ouput only paths and exit

build/assets/.datadir

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/deployConfig.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ module.exports = {
3333
allowElevation: true,
3434
allowToChangeInstallationDirectory: true,
3535
createDesktopShortcut: false,
36-
include: "build/installer.nsh",
3736
license: "LICENSE",
3837
oneClick: false,
3938
perMachine: false,

build/installer.nsh

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)