From 13f76d18613319441a79425f505812c284e96d7d Mon Sep 17 00:00:00 2001 From: fyne Date: Sat, 4 Sep 2021 11:42:13 +0100 Subject: [PATCH 1/3] Attempt to fix #166 Add better checks --- lib/cwtch/ffi.dart | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 82de6c74..bd8462d3 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -115,10 +115,19 @@ class CwtchFfi implements Cwtch { bundledTor = "Tor\\Tor\\tor.exe"; } else if (Platform.isMacOS) { cwtchDir = envVars['CWTCH_HOME'] ?? path.join(envVars['HOME']!, "Library/Application Support/Cwtch"); - if (await File("Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { - bundledTor = "Cwtch.app/Contents/MacOS/Tor/tor.real"; + if (await File("/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { + bundledTor = "/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real"; } else if (await File("/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { bundledTor = "/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real"; + } else { + var splitPath = path.split(dirname(Platform.script.path)); + if (splitPath[0] == "/" && splitPath[1] == "Applications"){ + var appName = splitPath[2]; + print("We're running in /Applications in a non standard app name: $appName"); + if (await File("/Applications/$appName/Contents/MacOS/Tor/tor.real").exists()) { + bundledTor = "/Applications/$appName/Contents/MacOS/Tor/tor.real"; + } + } } } From b53f43d946e2afad4f8af1b81f2e11943ed18a25 Mon Sep 17 00:00:00 2001 From: fyne Date: Sat, 4 Sep 2021 14:41:01 +0100 Subject: [PATCH 2/3] Allow the fallback to the Tor Browser tor.real --- lib/cwtch/ffi.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index bd8462d3..43f2aa32 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -119,6 +119,9 @@ class CwtchFfi implements Cwtch { bundledTor = "/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real"; } else if (await File("/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { bundledTor = "/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real"; + } else if (await File("/Applications/Tor Browser.app/Contents/MacOS/Tor/tor.real").exists()) { + bundledTor = "/Applications/Tor Browser.app/Contents/MacOS/Tor/tor.real"; + print("We couldn't find Tor in the Cwtch app directory, however we can fall back to the Tor Browser binary"); } else { var splitPath = path.split(dirname(Platform.script.path)); if (splitPath[0] == "/" && splitPath[1] == "Applications"){ From be0c4f4d644a23f5f5753818a8136d5f40607607 Mon Sep 17 00:00:00 2001 From: fyne Date: Sat, 4 Sep 2021 18:48:49 +0100 Subject: [PATCH 3/3] Leave the Cwtch.app local path in --- lib/cwtch/ffi.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cwtch/ffi.dart b/lib/cwtch/ffi.dart index 43f2aa32..8ab357c9 100644 --- a/lib/cwtch/ffi.dart +++ b/lib/cwtch/ffi.dart @@ -115,7 +115,9 @@ class CwtchFfi implements Cwtch { bundledTor = "Tor\\Tor\\tor.exe"; } else if (Platform.isMacOS) { cwtchDir = envVars['CWTCH_HOME'] ?? path.join(envVars['HOME']!, "Library/Application Support/Cwtch"); - if (await File("/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { + if (await File("Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { + bundledTor = "Cwtch.app/Contents/MacOS/Tor/tor.real"; + } else if (await File("/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { bundledTor = "/Applications/Cwtch.app/Contents/MacOS/Tor/tor.real"; } else if (await File("/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real").exists()) { bundledTor = "/Volumes/Cwtch/Cwtch.app/Contents/MacOS/Tor/tor.real";