Skip to content

Commit

Permalink
Do not cache lib-scan for 'unmanaged' paths
Browse files Browse the repository at this point in the history
Those are the paths given by --library / --libraries flags.
  • Loading branch information
cmaglie committed Oct 30, 2024
1 parent 15cf7d9 commit fe44665
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions internal/arduino/libraries/librariesmanager/librariesmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,23 +245,24 @@ func (lm *LibrariesManager) loadLibrariesFromDir(librariesDir *LibrariesDir) []*
loadedLibs = append(loadedLibs, library)
}

// Write lib cache
cache, err := cacheFilePath.Create()
if err != nil {
s := status.Newf(codes.FailedPrecondition, "creating lib cache %[1]s: %[2]s", cacheFilePath, err)
return append(statuses, s)
}
// Preload source files and header
for _, lib := range loadedLibs {
lib.SourceHeaders()
}
// Write the cache
err = loadedLibs.MarshalBinary(cache, librariesDir.Path)
cache.Close()
if err != nil {
cacheFilePath.Remove()
s := status.Newf(codes.FailedPrecondition, "writing lib cache %[1]s: %[2]s", cacheFilePath, err)
return append(statuses, s)
if librariesDir.Location != libraries.Unmanaged {
// Write lib cache
cache, err := cacheFilePath.Create()
if err != nil {
s := status.Newf(codes.FailedPrecondition, "creating lib cache %[1]s: %[2]s", cacheFilePath, err)
return append(statuses, s)
}
err = loadedLibs.MarshalBinary(cache, librariesDir.Path)
cache.Close()
if err != nil {
cacheFilePath.Remove()
s := status.Newf(codes.FailedPrecondition, "writing lib cache %[1]s: %[2]s", cacheFilePath, err)
return append(statuses, s)
}
}
}

Expand Down

0 comments on commit fe44665

Please sign in to comment.