Report or refuse each unusable file webhooker reads (closes #290)
check / check (push) Successful in 3m26s
check / check (push) Successful in 3m26s
Audit of the files webhooker reads configuration or required state from. A missing or zero-length database is reported with the "created a new, empty database" warning and its path: webhooker.db at start, and a per-webhook database at the latest at the next start, since restart recovery now opens every webhook's database. The main database's open errors name webhooker.db (#459). webhooker resetpw refuses a zero-length webhooker.db as it refuses a missing one. A directory in place of a database file or its -wal or -shm is refused, naming it; beside a -shm directory SQLite opened the database read-only without a word. The README says how each case is treated. Model: opus-5-5
This commit is contained in:
@@ -308,7 +308,7 @@ func checkDataDir(dir string) error {
|
||||
|
||||
dbPath := filepath.Join(dir, database.MainDBFileName)
|
||||
|
||||
_, err = os.Stat(dbPath)
|
||||
dbInfo, err := os.Stat(dbPath)
|
||||
|
||||
switch {
|
||||
case errors.Is(err, fs.ErrNotExist):
|
||||
@@ -319,6 +319,15 @@ func checkDataDir(dir string) error {
|
||||
)
|
||||
case err != nil:
|
||||
return fmt.Errorf("checking %s: %w", dbPath, err)
|
||||
case dbInfo.Size() == 0:
|
||||
// SQLite opens a zero-length file as an empty database, so
|
||||
// it holds no deployment either, and opening it would write
|
||||
// an empty schema into it.
|
||||
return fmt.Errorf(
|
||||
"%w: %s is zero-length. The admin account is created by "+
|
||||
"the first server start",
|
||||
ErrNoDatabase, dbPath,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user