fix: add panic recovery to auto-scan, cap DHT nodes at 200
This commit is contained in:
parent
c476bd865c
commit
3badde606e
2 changed files with 10 additions and 0 deletions
|
|
@ -536,6 +536,11 @@ func runAutoScan(ctx context.Context, cfg config.Config, interval time.Duration)
|
||||||
}
|
}
|
||||||
|
|
||||||
doScan := func() {
|
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)
|
log.Printf("[auto-scan] starting scan of %s", cfg.Library.ScanPath)
|
||||||
|
|
||||||
existing, _ := library.LoadCache()
|
existing, _ := library.LoadCache()
|
||||||
|
|
|
||||||
|
|
@ -642,6 +642,11 @@ func saveDhtNodesBinary(client *torrent.Client) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cap at 200 nodes to prevent unbounded file growth
|
||||||
|
if len(allNodes) > 200 {
|
||||||
|
allNodes = allNodes[:200]
|
||||||
|
}
|
||||||
|
|
||||||
path := dhtNodesBinPath()
|
path := dhtNodesBinPath()
|
||||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue