Disable multithreaded scanners for sqlite

as it's not reliable
This commit is contained in:
viktorstrate
2021-01-17 13:08:44 +01:00
parent fcdb5b4e7b
commit 50d0aa0efb
4 changed files with 45 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"time"
"github.com/photoview/photoview/api/database/drivers"
"github.com/photoview/photoview/api/graphql/models"
"github.com/photoview/photoview/api/scanner"
"github.com/pkg/errors"
@@ -66,6 +67,10 @@ func (r *mutationResolver) SetScannerConcurrentWorkers(ctx context.Context, work
return 0, errors.New("concurrent workers must at least be 1")
}
if workers > 1 && drivers.DatabaseDriver() == drivers.DatabaseDriverSqlite {
return 0, errors.New("multiple workers not supported for SQLite databases")
}
if err := r.Database.Session(&gorm.Session{AllowGlobalUpdate: true}).Model(&models.SiteInfo{}).Update("concurrent_workers", workers).Error; err != nil {
return 0, err
}