Skip to content

Commit bde00fa

Browse files
committed
fix: address lint issues and tracking bin
1 parent a4c08b4 commit bde00fa

4 files changed

Lines changed: 19 additions & 35 deletions

File tree

cmd/install/main.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,9 @@ func setupServices() {
335335
}
336336

337337
// Ensure local models dir exists
338-
os.MkdirAll(localModels, 0755)
338+
if err := os.MkdirAll(localModels, 0755); err != nil {
339+
fail(fmt.Sprintf("Could not create Ollama models dir: %v", err))
340+
}
339341

340342
args := []string{
341343
"-p", "11434:11434",
@@ -367,7 +369,12 @@ func startDockerContainer(name, image string, args []string, env []string) {
367369
}
368370

369371
// Remove if exists but stopped
370-
exec.Command("docker", "rm", name).Run()
372+
if err := exec.Command("docker", "rm", name).Run(); err != nil {
373+
// ignore if container didn't exist, but log other errors
374+
if exitErr, ok := err.(*exec.ExitError); !ok || exitErr.ExitCode() != 1 {
375+
warn(fmt.Sprintf("Failed to remove existing container %s: %v", name, err))
376+
}
377+
}
371378

372379
// Run
373380
runArgs := []string{"run", "-d", "--name", name, "--restart", "unless-stopped"}
@@ -663,7 +670,9 @@ func updateMCPConfig(ideKey, displayName, path, binPath string) {
663670

664671
// Read existing
665672
if data, err := os.ReadFile(path); err == nil {
666-
json.Unmarshal(data, &config)
673+
if err := json.Unmarshal(data, &config); err != nil {
674+
warn(fmt.Sprintf("Failed to parse existing MCP config %s: %v", path, err))
675+
}
667676
}
668677

669678
collectionKey := "mcpServers"

cmd/rag-code-mcp/main.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"os"
1212
"os/signal"
1313
"path/filepath"
14-
"runtime"
1514
"strings"
1615
"syscall"
1716
"time"
@@ -79,25 +78,6 @@ func (l *simpleLogger) Warn(format string, args ...interface{}) {
7978

8079
var logger = &simpleLogger{}
8180

82-
func getAppDataDir() (string, error) {
83-
home, err := os.UserHomeDir()
84-
if err != nil {
85-
return "", err
86-
}
87-
88-
if runtime.GOOS == "windows" {
89-
return filepath.Join(home, "AppData", "Local", "ragcode"), nil
90-
} else if runtime.GOOS == "darwin" {
91-
return filepath.Join(home, "Library", "Application Support", "ragcode"), nil
92-
}
93-
94-
// Linux / Unix standard (XDG state home or fallback to local/state)
95-
if xdgState := os.Getenv("XDG_STATE_HOME"); xdgState != "" {
96-
return filepath.Join(xdgState, "ragcode"), nil
97-
}
98-
return filepath.Join(home, ".local", "state", "ragcode"), nil
99-
}
100-
10181
func resolveLogPath(path string) (string, error) {
10282
if path == "" {
10383
return "", nil

internal/workspace/manager.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,6 @@ func (s *workspaceScan) fingerprint(language string) string {
158158
return fmt.Sprintf("%x", h.Sum64())
159159
}
160160

161-
// Helper to check if a slice contains a string
162-
func contains(slice []string, item string) bool {
163-
for _, s := range slice {
164-
if s == item {
165-
return true
166-
}
167-
}
168-
return false
169-
}
170-
171161
func (m *Manager) fingerprintKey(info *Info, language string) string {
172162
return info.ID + "-" + strings.ToLower(language)
173163
}

internal/workspace/watcher.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ func (fw *FileWatcher) Start() {
5656
if strings.HasPrefix(base, ".") && base != "." && base != ".git" {
5757
return filepath.SkipDir
5858
}
59-
return fw.watcher.Add(path)
59+
if err := fw.watcher.Add(path); err != nil {
60+
log.Printf("[WARN] Unable to watch %s: %v", path, err)
61+
}
62+
return nil
6063
}
6164
return nil
6265
})
@@ -90,7 +93,9 @@ func (fw *FileWatcher) watchLoop() {
9093
// Skip if ignored
9194
base := filepath.Base(event.Name)
9295
if _, skip := defaultSkipDirs[base]; !skip && !strings.HasPrefix(base, ".") {
93-
fw.watcher.Add(event.Name)
96+
if err := fw.watcher.Add(event.Name); err != nil {
97+
log.Printf("[WARN] Unable to watch new dir %s: %v", event.Name, err)
98+
}
9499
}
95100
}
96101
}

0 commit comments

Comments
 (0)