Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-01-17 21:50:31 +08:00
parent 6c2545e457
commit 95242c3f4d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 45 additions and 45 deletions

View file

@ -79,16 +79,16 @@ func initDatabase(forceRebuild bool) (err error) {
func initDBTables() {
_, err := db.Exec("DROP TABLE IF EXISTS blocktrees")
if err != nil {
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "drop table [blocks] failed: %s", err)
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "drop table [blocks] failed: %s", err)
}
_, err = db.Exec("CREATE TABLE blocktrees (id, root_id, parent_id, box_id, path, hpath, updated, type)")
if err != nil {
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create table [blocktrees] failed: %s", err)
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "create table [blocktrees] failed: %s", err)
}
_, err = db.Exec("CREATE INDEX idx_blocktrees_id ON blocktrees(id)")
if err != nil {
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create index [idx_blocktrees_id] failed: %s", err)
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "create index [idx_blocktrees_id] failed: %s", err)
}
}
@ -111,7 +111,7 @@ func initDBConnection() {
var err error
db, err = sql.Open("sqlite3_extended", dsn)
if err != nil {
logging.LogFatalf(logging.ExitCodeReadOnlyDatabase, "create database failed: %s", err)
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "create database failed: %s", err)
}
db.SetMaxIdleConns(7)
db.SetMaxOpenConns(7)
@ -654,7 +654,7 @@ func InitBlockTree(force bool) {
err := initDatabase(force)
if err != nil {
logging.LogErrorf("init database failed: %s", err)
os.Exit(logging.ExitCodeReadOnlyDatabase)
os.Exit(logging.ExitCodeUnavailableDatabase)
return
}
return