Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configs/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions configs/preferences_txt_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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)
Expand Down