From 0db0610a239c524391ce357eb5994e45c235a8a1 Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 19 Jan 2022 12:59:39 -0800 Subject: [PATCH 1/2] Fix Tor Reset to Update Settings and Avoid Contention on datadir --- lib.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib.go b/lib.go index 26fb84a..dbf1554 100644 --- a/lib.go +++ b/lib.go @@ -800,7 +800,15 @@ func c_ResetTor() { func ResetTor() { log.Infof("Replacing ACN with new Tor...") - globalACN.ReplaceACN(buildACN(*utils.ReadGlobalSettings(), globalTorPath, globalAppDir)) + settings := utils.ReadGlobalSettings() + log.Infof("Settings on Reset: %v", settings) + globalACN.Close() // we need to close first if dateDir is the same, otherwise buildACN can't launch tor. + globalACN.ReplaceACN(buildACN(*settings, globalTorPath, globalAppDir)) + + // We need to update settings on reset as buildACN can alter settings, otherwise the next reset will be broken... + settings = utils.ReadGlobalSettings() + settingsJson, _ := json.Marshal(settings) + application.GetPrimaryBus().Publish(event.NewEvent(utils.UpdateGlobalSettings, map[event.Field]string{event.Data: string(settingsJson)})) log.Infof("Restarted") } From 5e4e3d40830907a42b1d725db25b59d2b2029f5b Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Wed, 19 Jan 2022 13:00:32 -0800 Subject: [PATCH 2/2] Remove Settings Log --- lib.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.go b/lib.go index dbf1554..2838c2b 100644 --- a/lib.go +++ b/lib.go @@ -801,7 +801,7 @@ func c_ResetTor() { func ResetTor() { log.Infof("Replacing ACN with new Tor...") settings := utils.ReadGlobalSettings() - log.Infof("Settings on Reset: %v", settings) + globalACN.Close() // we need to close first if dateDir is the same, otherwise buildACN can't launch tor. globalACN.ReplaceACN(buildACN(*settings, globalTorPath, globalAppDir))