mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Improve profile detection. Fix #498
Warn if multiple active profiles are detected and don't look for lock files that are deeper in the profile directory.
This commit is contained in:
parent
dbdbfb0322
commit
91ab52b7d5
2 changed files with 18 additions and 11 deletions
|
@ -226,10 +226,6 @@ export async function guiset(rule: string, option: string) {
|
|||
return
|
||||
}
|
||||
} else profile_dir = config.get("profiledir")
|
||||
if (profile_dir == "") {
|
||||
logger.error("Profile not found.")
|
||||
return
|
||||
}
|
||||
|
||||
// Make backups
|
||||
await Native.mkdir(profile_dir + "/chrome", true)
|
||||
|
|
|
@ -169,16 +169,27 @@ export async function run(command: string) {
|
|||
|
||||
export async function getProfileDir() {
|
||||
// Find active profile directory automatically by seeing where the lock exists
|
||||
let hacky_profile_finder = "find ../../../.mozilla/firefox -name lock"
|
||||
let hacky_profile_finder =
|
||||
"find ../../../.mozilla/firefox -maxdepth 2 -name lock"
|
||||
if ((await browser.runtime.getPlatformInfo()).os === "mac")
|
||||
hacky_profile_finder =
|
||||
"find ../../../Library/'Application Support'/Firefox/Profiles -maxdepth 2 -name .parentlock"
|
||||
let profilecmd = await run(hacky_profile_finder)
|
||||
if (profilecmd.code != 0) {
|
||||
return ""
|
||||
} else
|
||||
return profilecmd.content
|
||||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")
|
||||
throw new Error("Profile not found")
|
||||
} else {
|
||||
// Remove trailing newline
|
||||
profilecmd.content = profilecmd.content.trim()
|
||||
if (profilecmd.content.split("\n").length > 1) {
|
||||
throw new Error(
|
||||
"Multiple profiles in use. Can't tell which one you want. `set profiledir`, close other Firefox profiles or remove zombie lock files.",
|
||||
)
|
||||
} else {
|
||||
// Get parent directory of lock file
|
||||
return profilecmd.content
|
||||
.split("/")
|
||||
.slice(0, -1)
|
||||
.join("/")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue