Skip to content

Commit cc24beb

Browse files
committed
loopd: always skip migration if loop_sqlite.db file already exists
This commit ensures that we don't even check for the existence of the loop.db file if loop_sqlite.db already present. This is to ensure that on systems that may by any trigger restore deleted files we don't try to re-run migration which would otherwise make loopd unable to start up properly.
1 parent 6a145ea commit cc24beb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

loopd/migration.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ func needSqlMigration(cfg *Config) bool {
8282
return false
8383
}
8484

85+
// Do not migrate if sqlite db already exists. This is to prevent the
86+
// migration from running multiple times for systems that may restore
87+
// any deleted files occasionally (reboot, etc).
88+
sqliteDBPath := filepath.Join(cfg.DataDir, "loop_sqlite.db")
89+
if lnrpc.FileExists(sqliteDBPath) {
90+
log.Infof("Found sqlite db at %v, skipping migration",
91+
sqliteDBPath)
92+
93+
return false
94+
}
95+
8596
// Now we'll check if the bolt db exists.
8697
if !lnrpc.FileExists(filepath.Join(cfg.DataDir, "loop.db")) {
8798
return false

0 commit comments

Comments
 (0)