chore(sqlite): linter complaints

This commit is contained in:
Jakob Borg
2025-06-06 13:45:44 +02:00
parent 3c92999406
commit ef6d561c66
8 changed files with 30 additions and 16 deletions
+1 -1
View File
@@ -255,7 +255,7 @@ func (s *DB) ListDevicesForFolder(folder string) ([]protocol.DeviceID, error) {
func (s *DB) RemoteSequences(folder string) (map[protocol.DeviceID]int64, error) {
fdb, err := s.getFolderDB(folder, false)
if errors.Is(err, errNoSuchFolder) {
return nil, nil
return nil, nil //nolint:nilnil
}
if err != nil {
return nil, err
+12 -4
View File
@@ -50,10 +50,14 @@ func Open(path string, opts ...Option) (*DB, error) {
"sql/schema/common/*",
"sql/schema/main/*",
}
migrations := []string{
"sql/migrations/common/*",
"sql/migrations/main/*",
}
os.MkdirAll(path, 0o700)
_ = os.MkdirAll(path, 0o700)
mainPath := filepath.Join(path, "main.db")
mainBase, err := openBase(mainPath, maxDBConns, pragmas, schemas, nil)
mainBase, err := openBase(mainPath, maxDBConns, pragmas, schemas, migrations)
if err != nil {
return nil, err
}
@@ -88,10 +92,14 @@ func OpenForMigration(path string) (*DB, error) {
"sql/schema/common/*",
"sql/schema/main/*",
}
migrations := []string{
"sql/migrations/common/*",
"sql/migrations/main/*",
}
os.MkdirAll(path, 0o700)
_ = os.MkdirAll(path, 0o700)
mainPath := filepath.Join(path, "main.db")
mainBase, err := openBase(mainPath, 1, pragmas, schemas, nil)
mainBase, err := openBase(mainPath, 1, pragmas, schemas, migrations)
if err != nil {
return nil, err
}
+5 -3
View File
@@ -84,8 +84,11 @@ func (s *Service) periodic(ctx context.Context) error {
defer func() { l.Debugln("Periodic done in", time.Since(t1), "+", t1.Sub(t0)) }()
s.sdb.updateLock.Lock()
tidy(ctx, s.sdb.sql)
err := tidy(ctx, s.sdb.sql)
s.sdb.updateLock.Unlock()
if err != nil {
return err
}
return wrap(s.sdb.forEachFolder(func(fdb *folderDB) error {
fdb.updateLock.Lock()
@@ -97,8 +100,7 @@ func (s *Service) periodic(ctx context.Context) error {
if err := garbageCollectBlocklistsAndBlocksLocked(ctx, fdb); err != nil {
return wrap(err)
}
tidy(ctx, fdb.sql)
return nil
return tidy(ctx, fdb.sql)
}))
}
+5 -1
View File
@@ -32,8 +32,12 @@ func openFolderDB(folder, path string, deleteRetention time.Duration) (*folderDB
"sql/schema/common/*",
"sql/schema/folder/*",
}
migrations := []string{
"sql/migrations/common/*",
"sql/migrations/folder/*",
}
base, err := openBase(path, maxDBConns, pragmas, schemas, nil)
base, err := openBase(path, maxDBConns, pragmas, schemas, migrations)
if err != nil {
return nil, err
}
+5 -4
View File
@@ -433,7 +433,7 @@ type fileRow struct {
func (e fileRow) Compare(other fileRow) int {
// From FileInfo.WinsConflict
vc := e.Version.Vector.Compare(other.Version.Vector)
vc := e.Version.Compare(other.Version.Vector)
switch vc {
case protocol.Equal:
if e.Invalid != other.Invalid {
@@ -519,11 +519,12 @@ func (s *folderDB) periodicCheckpointLocked(fs []protocol.FileInfo) {
// failed, we'll keep trying it until we succeed. Increase it faster
// when we fail to checkpoint, as it's more likely the WAL is
// growing and will need truncation when we get out of this state.
if res == 1 {
switch {
case res == 1:
s.checkpointsCount += 10
} else if res == 0 && checkpointType == "TRUNCATE" {
case res == 0 && checkpointType == "TRUNCATE":
s.checkpointsCount = 0
} else {
default:
s.checkpointsCount++
}
s.updatePoints = 0