diff --git a/internal/cmd/daemon.go b/internal/cmd/daemon.go index f7e5de4..f9a2a88 100644 --- a/internal/cmd/daemon.go +++ b/internal/cmd/daemon.go @@ -536,6 +536,11 @@ func runAutoScan(ctx context.Context, cfg config.Config, interval time.Duration) } doScan := func() { + defer func() { + if r := recover(); r != nil { + log.Printf("[auto-scan] panic recovered: %v", r) + } + }() log.Printf("[auto-scan] starting scan of %s", cfg.Library.ScanPath) existing, _ := library.LoadCache() diff --git a/internal/engine/torrent.go b/internal/engine/torrent.go index 5bcc561..56bf08a 100644 --- a/internal/engine/torrent.go +++ b/internal/engine/torrent.go @@ -642,6 +642,11 @@ func saveDhtNodesBinary(client *torrent.Client) { return } + // Cap at 200 nodes to prevent unbounded file growth + if len(allNodes) > 200 { + allNodes = allNodes[:200] + } + path := dhtNodesBinPath() if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil { return