fix: on macOS remove -psn_... cli params before processing with confutils

This commit is contained in:
Michael Bradley, Jr 2021-06-03 13:37:27 -05:00 committed by Michael Bradley
parent ae6dc8e9f4
commit 816b2f0ee9
1 changed files with 16 additions and 4 deletions

View File

@ -1,6 +1,8 @@
import confutils
import json
import os
import # std libs
json, os, sequtils, strutils
import # vendor libs
confutils
const GENERATED* = "generated"
const SEED* = "seed"
@ -202,7 +204,17 @@ type StatusDesktopConfig = object
desc: "Status Desktop data directory"
abbr: "d" .}: string
let desktopConfig = StatusDesktopConfig.load()
# On macOS the first time when a user gets the "App downloaded from the
# internet" warning, and clicks the Open button, the OS passes a unique process
# serial number (PSN) as -psn_... command-line argument, which we remove before
# processing the arguments with nim-confutils.
# Credit: https://github.com/bitcoin/bitcoin/blame/b6e34afe9735faf97d6be7a90fafd33ec18c0cbb/src/util/system.cpp#L383-L389
var cliParams = commandLineParams()
if defined(macosx):
cliParams.keepIf(proc(p: string): bool = not p.startsWith("-psn_"))
let desktopConfig = StatusDesktopConfig.load(cliParams)
let
baseDir = absolutePath(expandTilde(desktopConfig.dataDir))