mirror of
https://github.com/syncthing/syncthing.git
synced 2026-05-18 22:03:11 -04:00
chore(syncthing): ensure migrated database is closed before exiting (#10076)
After opening the database, we performed some checks, such as whether the migration had already been successfully completed. If so, the function returned immediately, and the database was not closed. --------- Co-authored-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -170,11 +170,13 @@ func TryMigrateDatabase(deleteRetention time.Duration) error {
|
||||
// Apparently, not a valid old database
|
||||
return nil
|
||||
}
|
||||
defer be.Close()
|
||||
|
||||
sdb, err := sqlite.OpenForMigration(locations.Get(locations.Database))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer sdb.Close()
|
||||
|
||||
miscDB := db.NewMiscDB(sdb)
|
||||
if when, ok, err := miscDB.Time("migrated-from-leveldb-at"); err == nil && ok {
|
||||
@@ -265,8 +267,7 @@ func TryMigrateDatabase(deleteRetention time.Duration) error {
|
||||
_ = miscDB.PutTime("migrated-from-leveldb-at", time.Now())
|
||||
_ = miscDB.PutString("migrated-from-leveldb-by", build.LongVersion)
|
||||
|
||||
be.Close()
|
||||
sdb.Close()
|
||||
_ = be.Close()
|
||||
_ = os.Rename(oldDBDir, oldDBDir+"-migrated")
|
||||
|
||||
l.Infof("Migration complete, %d files and %dk blocks in %s", totFiles, totBlocks/1000, time.Since(t0).Truncate(time.Second))
|
||||
|
||||
Reference in New Issue
Block a user