Show database file size on info page

This commit is contained in:
2022-08-21 13:24:52 +09:30
parent a03baca498
commit f98df478bb
7 changed files with 25 additions and 10 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log"
"os"
"strings"
"sync"
"time"
@@ -286,5 +287,11 @@ func (m *BookmarkManager) Stats() (entity.DBStats, error) {
if err != nil && err != bolthold.ErrNotFound {
return stats, fmt.Errorf("could not load stats: %s", err)
}
// get the DB size
fi, err := os.Stat(m.db.file)
if err != nil {
return stats, fmt.Errorf("could not load db file size: %s", err)
}
stats.FileSize = int(fi.Size())
return stats, nil
}

View File

@@ -10,6 +10,7 @@ import (
type DB struct {
store *bolthold.Store
file string
}
func (db *DB) Open(path string) error {
@@ -21,6 +22,7 @@ func (db *DB) Open(path string) error {
return fmt.Errorf("cannot open '%s' - %s", path, err)
}
db.store = store
db.file = path
return nil
}