Add structured logging and better error handling
This commit is contained in:
1 parent
db4e3c9611
commit
68c7dd76f2
31 files changed
+640
-109
No files matched your search
@@ -2,6 +2,7 @@ package jobs
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"log/slog"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
@@ -20,12 +21,14 @@ func (manager *Manager) RestoreExisting() error {
|
||||
}
|
||||
|
||||
var queuedJobs []*Job
|
||||
restoredCount := 0
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() || !jobIDPattern.MatchString(entry.Name()) {
|
||||
continue
|
||||
}
|
||||
job := manager.restoreJob(entry)
|
||||
manager.store(job)
|
||||
restoredCount++
|
||||
if job.status == StatusQueued {
|
||||
queuedJobs = append(queuedJobs, job)
|
||||
}
|
||||
@@ -38,6 +41,7 @@ func (manager *Manager) RestoreExisting() error {
|
||||
job.workers.Add(1)
|
||||
manager.launchDownload(job)
|
||||
}
|
||||
slog.Info("restored downloads", "total", restoredCount, "resuming", len(queuedJobs))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user