mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 18:29:17 +00:00
Add admin setting to change max concurrent workers
This commit is contained in:
@@ -62,3 +62,25 @@ func (r *mutationResolver) SetPeriodicScanInterval(ctx context.Context, interval
|
||||
|
||||
return dbInterval, nil
|
||||
}
|
||||
|
||||
func (r *mutationResolver) SetScannerConcurrentWorkers(ctx context.Context, workers int) (int, error) {
|
||||
if workers < 0 {
|
||||
return 0, errors.New("concurrent workers must be positive")
|
||||
}
|
||||
|
||||
_, err := r.Database.Exec("UPDATE site_info SET concurrent_workers = ?", workers)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var dbWorkers int
|
||||
|
||||
row := r.Database.QueryRow("SELECT concurrent_workers FROM site_info")
|
||||
if err = row.Scan(&dbWorkers); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
scanner.ChangeScannerConcurrentWorkers(dbWorkers)
|
||||
|
||||
return dbWorkers, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user