Merge pull request 'Remove wal and shm deletion' (#55) from no-text-input-for-wifi-password into dev

Reviewed-on: https://codeberg.org/RhemaWave-Technologies/RhemaWave/pulls/55
This commit is contained in:
NeilClack
2026-06-27 22:12:11 +02:00
+13 -14
View File
@@ -8,7 +8,6 @@ package db
import (
"fmt"
"os"
"time"
"gorm.io/driver/sqlite"
@@ -34,19 +33,19 @@ func Connect(dbpath string) (*gorm.DB, error) {
// safe: SQLite treats absent WAL/SHM files as a clean slate and will
// recreate them. We only do this if the main DB file already exists
// (i.e. this is not a first-run) to avoid masking legitimate errors.
if _, err := os.Stat(dbpath); err == nil {
for _, ext := range []string{"-wal", "-shm"} {
artefact := dbpath + ext
if _, err := os.Stat(artefact); err == nil {
if removeErr := os.Remove(artefact); removeErr != nil {
// Non-fatal: log and continue — SQLite may still recover.
fmt.Printf("[DB] warning: could not remove stale %s: %v\n", ext, removeErr)
} else {
fmt.Printf("[DB] removed stale lock artefact: %s\n", artefact)
}
}
}
}
// if _, err := os.Stat(dbpath); err == nil {
// for _, ext := range []string{"-wal", "-shm"} {
// artefact := dbpath + ext
// if _, err := os.Stat(artefact); err == nil {
// if removeErr := os.Remove(artefact); removeErr != nil {
// // Non-fatal: log and continue — SQLite may still recover.
// fmt.Printf("[DB] warning: could not remove stale %s: %v\n", ext, removeErr)
// } else {
// fmt.Printf("[DB] removed stale lock artefact: %s\n", artefact)
// }
// }
// }
// }
// ── Connection with retry ─────────────────────────────────────────────
// Even after removing WAL/SHM, the main DB file itself may still be