Skip to content

Commit fe44665

Browse files
committed
Do not cache lib-scan for 'unmanaged' paths
Those are the paths given by --library / --libraries flags.
1 parent 15cf7d9 commit fe44665

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

internal/arduino/libraries/librariesmanager/librariesmanager.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,24 @@ func (lm *LibrariesManager) loadLibrariesFromDir(librariesDir *LibrariesDir) []*
245245
loadedLibs = append(loadedLibs, library)
246246
}
247247

248-
// Write lib cache
249-
cache, err := cacheFilePath.Create()
250-
if err != nil {
251-
s := status.Newf(codes.FailedPrecondition, "creating lib cache %[1]s: %[2]s", cacheFilePath, err)
252-
return append(statuses, s)
253-
}
254248
// Preload source files and header
255249
for _, lib := range loadedLibs {
256250
lib.SourceHeaders()
257251
}
258-
// Write the cache
259-
err = loadedLibs.MarshalBinary(cache, librariesDir.Path)
260-
cache.Close()
261-
if err != nil {
262-
cacheFilePath.Remove()
263-
s := status.Newf(codes.FailedPrecondition, "writing lib cache %[1]s: %[2]s", cacheFilePath, err)
264-
return append(statuses, s)
252+
if librariesDir.Location != libraries.Unmanaged {
253+
// Write lib cache
254+
cache, err := cacheFilePath.Create()
255+
if err != nil {
256+
s := status.Newf(codes.FailedPrecondition, "creating lib cache %[1]s: %[2]s", cacheFilePath, err)
257+
return append(statuses, s)
258+
}
259+
err = loadedLibs.MarshalBinary(cache, librariesDir.Path)
260+
cache.Close()
261+
if err != nil {
262+
cacheFilePath.Remove()
263+
s := status.Newf(codes.FailedPrecondition, "writing lib cache %[1]s: %[2]s", cacheFilePath, err)
264+
return append(statuses, s)
265+
}
265266
}
266267
}
267268

0 commit comments

Comments
 (0)