🎨 Improve reindex

Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
Daniel 2026-03-09 11:25:05 +08:00
parent ecfb9329f9
commit f7f05ffad1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 51 additions and 52 deletions

View file

@ -559,3 +559,30 @@ func LogDatabaseSize(dbPath string) {
dbSize := humanize.BytesCustomCeil(uint64(dbFile.Size()), 2)
logging.LogInfof("database [%s] size [%s]", dbPath, dbSize)
}
func RemoveDatabaseFile(dbPath string) {
if gulu.File.IsExist(dbPath) {
err := os.RemoveAll(dbPath)
if err != nil {
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "remove database file [%s] failed: %s", dbPath, err)
return
}
}
if gulu.File.IsExist(dbPath + "-shm") {
err := os.RemoveAll(dbPath + "-shm")
if err != nil {
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "remove database file [%s] failed: %s", dbPath+"-shm", err)
return
}
}
if gulu.File.IsExist(dbPath + "-wal") {
err := os.RemoveAll(dbPath + "-wal")
if err != nil {
logging.LogFatalf(logging.ExitCodeUnavailableDatabase, "remove database file [%s] failed: %s", dbPath+"-wal", err)
return
}
}
return
}