Password: fail loudly when settings cannot be saved (#30767)

This commit is contained in:
andig 2026-06-12 23:51:03 +02:00 • committed by GitHub
parent cb09fccd34
commit c92fb3a4f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/mitchellh/go-homedir"
"gorm.io/gorm"
sqlite3 "modernc.org/sqlite"
sqlite3lib "modernc.org/sqlite/lib"
)
var (
@ -112,6 +113,13 @@ func Close() error {
return db.Close()
}
// IsReadonly reports whether err indicates a database file that is not
// writable by the current user. The code mask covers extended result codes.
func IsReadonly(err error) bool {
var serr *sqlite3.Error
return errors.As(err, &serr) && serr.Code()&0xff == sqlite3lib.SQLITE_READONLY
}
type backuper interface {
NewBackup(string) (*sqlite3.Backup, error)
NewRestore(string) (*sqlite3.Backup, error)