Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5a33829

Browse files
dido18lucarin91
andauthored
fix: install a library missing from local library-index (#50)
* feat: enhance AddSketchLibrary to update library index and log progress* fix: improve library index update handling in AddSketchLibrary* fix: improve error handling in AddSketchLibrary by logging warnings instead of failing on library index update* fix: extend library index update interval to 60 seconds for improved performance* fix: update library index refresh interval to 10 minutes for improved performance* fix: improve error handling in AddSketchLibrary by logging warnings for library index update failures* Update internal/orchestrator/sketch_libs.goCo-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>* Update internal/orchestrator/sketch_libs.goCo-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>---------Co-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>
1 parentc64fbf6 commit5a33829

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎internal/orchestrator/sketch_libs.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ package orchestrator
1717

1818
import (
1919
"context"
20+
"log/slog"
21+
"time"
2022

2123
"github.com/arduino/arduino-cli/commands"
2224
rpc"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
@@ -25,6 +27,8 @@ import (
2527
"github.com/arduino/arduino-app-cli/internal/orchestrator/app"
2628
)
2729

30+
constindexUpdateInterval=10*time.Minute
31+
2832
funcAddSketchLibrary(ctx context.Context,app app.ArduinoApp,libRefLibraryReleaseID,addDepsbool) ([]LibraryReleaseID,error) {
2933
srv:=commands.NewArduinoCoreServer()
3034
varinst*rpc.Instance
@@ -43,6 +47,15 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
4347
returnnil,err
4448
}
4549

50+
stream,_:=commands.UpdateLibrariesIndexStreamResponseToCallbackFunction(ctx,func(curr*rpc.DownloadProgress) {
51+
slog.Debug("downloading library index","progress",curr.GetMessage())
52+
})
53+
// update the local library index after a certain time, to avoid if a library is added to the sketch but the local library index is not update, the compile can fail (because the lib is not found)
54+
req:=&rpc.UpdateLibrariesIndexRequest{Instance:inst,UpdateIfOlderThanSecs:int64(indexUpdateInterval.Seconds())}
55+
iferr:=srv.UpdateLibrariesIndex(req,stream);err!=nil {
56+
slog.Warn("error updating library index, skipping",slog.String("error",err.Error()))
57+
}
58+
4659
resp,err:=srv.ProfileLibAdd(ctx,&rpc.ProfileLibAddRequest{
4760
Instance:inst,
4861
SketchPath:app.MainSketchPath.String(),
@@ -59,6 +72,7 @@ func AddSketchLibrary(ctx context.Context, app app.ArduinoApp, libRef LibraryRel
5972
iferr!=nil {
6073
returnnil,err
6174
}
75+
6276
returnf.Map(resp.GetAddedLibraries(),rpcProfileLibReferenceToLibReleaseID),nil
6377
}
6478

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp