Skip to content

Commit d2c5328

Browse files
authored
Merge pull request #627 from bhandras/skip-migration-on-existing-db
loopd: always skip migration if `loop_sqlite.db` file already exists
2 parents 6a145ea + cc24beb commit d2c5328

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)