Skip to content

Commit

Permalink
Change finding out whether the application is a portable instance
Browse files Browse the repository at this point in the history
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
  • Loading branch information
c3er committed Dec 18, 2024
1 parent c675f7f commit c1ae9a9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
17 changes: 6 additions & 11 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const storage = require("./lib/storageMain")
const toc = require("./lib/tocMain")
const zoom = require("./lib/zoomMain")

const DATA_DIR_FILE = ".datadir"
const USER_DATA_PLACEHOLDER = "MDVIEW_USER_DATA"

const MIN_WINDOW_WIDTH = 200 // Pixels
const MIN_WINDOW_HEIGHT = 50 // Pixels
const UPDATE_INTERVAL = 1000 // ms
Expand Down Expand Up @@ -601,14 +598,12 @@ if (cli.isDevelopment()) {
"userData",
path.join(path.resolve(args.slice(1).find(arg => !arg.startsWith("-"))), ".data"),
)
} else if (process.platform === "win32") {
const dataPath = fs.readFileSync(path.join(appDir, DATA_DIR_FILE), { encoding: "utf-8" }).trim()
if (dataPath !== USER_DATA_PLACEHOLDER) {
electron.app.setPath(
"userData",
path.isAbsolute(dataPath) ? dataPath : path.join(appDir, ".data"),
)
}
} else if (
process.platform === "win32" &&
!appDir.startsWith(process.env.ProgramFiles) &&
!appDir.startsWith(process.env.LOCALAPPDATA)
) {
electron.app.setPath("userData", path.join(appDir, ".data"))
}

// If set, ouput only paths and exit
Expand Down
1 change: 0 additions & 1 deletion build/assets/.datadir

This file was deleted.

1 change: 0 additions & 1 deletion build/deployConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module.exports = {
allowElevation: true,
allowToChangeInstallationDirectory: true,
createDesktopShortcut: false,
include: "build/installer.nsh",
license: "LICENSE",
oneClick: false,
perMachine: false,
Expand Down
7 changes: 0 additions & 7 deletions build/installer.nsh

This file was deleted.

0 comments on commit c1ae9a9

Please sign in to comment.