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..d8242b29a2a 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 { @@ -78,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)