From 816b2f0ee9f26532c763ea26047eab0b52fc75ef Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Thu, 3 Jun 2021 13:37:27 -0500 Subject: [PATCH] fix: on macOS remove -psn_... cli params before processing with confutils --- src/status/libstatus/accounts/constants.nim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/status/libstatus/accounts/constants.nim b/src/status/libstatus/accounts/constants.nim index 61797f8107..3611c57b59 100644 --- a/src/status/libstatus/accounts/constants.nim +++ b/src/status/libstatus/accounts/constants.nim @@ -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))