Skip to content

Commit 67e8fea

Browse files
committed
fix: resolve golangci-lint errcheck and staticcheck issues
- cmd/intercept/main.go: explicitly discard db.Close() errors (3x) - internal/setup/wizard.go: explicitly discard Close/RemoveAll errors (3x) - internal/svc/daemon_rpc_memory.go: apply De Morgan's law (QF1001)
1 parent 45e061a commit 67e8fea

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

cmd/intercept/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ func initGraphIndexer() *goragindexer.GraphIndexer {
189189
modelPath := filepath.Join(dataDir, "models", "model_q4.onnx")
190190
if _, err := os.Stat(modelPath); err != nil {
191191
fmt.Printf(" [KB] embedder model not found at %s\n", modelPath)
192-
db.Close()
192+
_ = db.Close()
193193
return nil
194194
}
195195

196196
emb, err := embedder.NewChineseClipEmbedder(embedder.WithModelFile(modelPath))
197197
if err != nil {
198198
fmt.Printf(" [KB] cannot initialize embedder: %v\n", err)
199-
db.Close()
199+
_ = db.Close()
200200
return nil
201201
}
202202

@@ -209,7 +209,7 @@ func initGraphIndexer() *goragindexer.GraphIndexer {
209209
)
210210
if err != nil {
211211
fmt.Printf(" [KB] cannot open vector store: %v\n", err)
212-
db.Close()
212+
_ = db.Close()
213213
return nil
214214
}
215215

internal/setup/wizard.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,15 +852,15 @@ func (m *firstRunModel) runEmbedderDownload(taskIdx int) {
852852
m.markTaskDone(taskIdx, taskFailed, err, "")
853853
return
854854
}
855-
defer src.Close()
855+
defer func() { _ = src.Close() }()
856856

857857
dst, err := os.Create(dstPath)
858858
if err != nil {
859859
m.downloadCh <- downloadProgressMsg{Done: true, Err: fmt.Errorf(i18n.T("setup.memory.model.create.failed"), err)}
860860
m.markTaskDone(taskIdx, taskFailed, err, "")
861861
return
862862
}
863-
defer dst.Close()
863+
defer func() { _ = dst.Close() }()
864864

865865
if _, err := io.Copy(dst, src); err != nil {
866866
m.downloadCh <- downloadProgressMsg{Done: true, Err: fmt.Errorf(i18n.T("setup.memory.model.copy.failed"), err)}
@@ -869,7 +869,7 @@ func (m *firstRunModel) runEmbedderDownload(taskIdx int) {
869869
}
870870

871871
srcDir := filepath.Join(cacheDir, strings.ReplaceAll(modelID, "/", string(filepath.Separator)))
872-
os.RemoveAll(srcDir)
872+
_ = os.RemoveAll(srcDir)
873873

874874
m.downloadCh <- downloadProgressMsg{
875875
Done: true,

internal/svc/daemon_rpc_memory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func (d *Daemon) handleFilewatchStatus(_ context.Context, _ json.RawMessage) (an
497497
continue
498498
}
499499
// Only reconcile entries that look like they were never synced.
500-
if st.State != "pending" && !(st.State == "indexing" && st.TotalFiles == 0 && st.IndexedFiles == 0) {
500+
if st.State != "pending" && (st.State != "indexing" || st.TotalFiles != 0 || st.IndexedFiles != 0) {
501501
continue
502502
}
503503
cacheDir := filepath.Join(status.CacheBase, kbwatch.SanitizeDirName(dir))

0 commit comments

Comments
 (0)