From f566d0eec47b71b2ced4995464872d8b40362029 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 9 Jan 2019 09:09:52 +0100 Subject: [PATCH 1/2] Recognize if IDE is portable and fix paths accordingly --- configs/configuration.go | 3 +++ configs/preferences_txt_serializer.go | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/configs/configuration.go b/configs/configuration.go index 2518e7ee96a..ea235c79aff 100644 --- a/configs/configuration.go +++ b/configs/configuration.go @@ -39,6 +39,9 @@ type Configuration struct { // ArduinoIDEDirectory is the directory of the Arduino IDE if the CLI runs together with it. ArduinoIDEDirectory *paths.Path + // IsPortable is set to true if the cli lives in IDE directory and the IDE is portable + IsPortable bool + // downloadsDir is the directory where the package files are downloaded and cached. // Use DownloadsDir() method to retrieve it. downloadsDir *paths.Path diff --git a/configs/preferences_txt_serializer.go b/configs/preferences_txt_serializer.go index 20ed1c6dd8a..c8b632f3df7 100644 --- a/configs/preferences_txt_serializer.go +++ b/configs/preferences_txt_serializer.go @@ -62,6 +62,12 @@ func (config *Configuration) IsBundledInDesktopIDE() bool { } } + portable := "portable" + if ideDir.Join(portable).Exist() { + logrus.Info("IDE is portable") + config.IsPortable = true + } + config.ArduinoIDEDirectory = ideDir res = true return true @@ -70,6 +76,10 @@ func (config *Configuration) IsBundledInDesktopIDE() bool { // LoadFromDesktopIDEPreferences loads the config from the Desktop IDE preferences.txt file func (config *Configuration) LoadFromDesktopIDEPreferences() error { logrus.Info("Unserializing from IDE preferences") + if config.IsPortable { + config.DataDir = config.ArduinoIDEDirectory.Join("portable") + config.SketchbookDir = config.ArduinoIDEDirectory.Join("portable").Join("sketchbook") + } preferenceTxtPath := config.DataDir.Join("preferences.txt") props, err := properties.LoadFromPath(preferenceTxtPath) if err != nil { From b71fd460790a7168eb54cf4372d7c49bea86d433 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 9 Jan 2019 09:10:17 +0100 Subject: [PATCH 2/2] Only report warning if proxy settings are bogus --- configs/preferences_txt_serializer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/configs/preferences_txt_serializer.go b/configs/preferences_txt_serializer.go index c8b632f3df7..d8242b29a2a 100644 --- a/configs/preferences_txt_serializer.go +++ b/configs/preferences_txt_serializer.go @@ -88,8 +88,7 @@ func (config *Configuration) LoadFromDesktopIDEPreferences() error { } err = config.proxyConfigsFromIDEPrefs(props) if err != nil { - logrus.WithError(err).Warn("Error during unserialize from IDE preferences") - return err + logrus.WithError(err).Warn("Error loading proxy settings from IDE preferences") } if dir, has := props.GetOk("sketchbook.path"); has { config.SketchbookDir = paths.New(dir)