Remove tmp files on start up

This commit is contained in:
Ben Johnson
2020-12-24 16:42:45 -07:00
parent 87c8cea851
commit 89fd441e9a
3 changed files with 25 additions and 0 deletions

5
db.go
View File

@@ -163,6 +163,11 @@ func (db *DB) Open() (err error) {
m[r.Name()] = struct{}{}
}
// Clear old temporary files that my have been left from a crash.
if err := removeTmpFiles(db.MetaPath()); err != nil {
return fmt.Errorf("cannot remove tmp files: %w", err)
}
// Start monitoring SQLite database in a separate goroutine.
db.wg.Add(1)
go func() { defer db.wg.Done(); db.monitor() }()