Merge pull request #11 from aerth/invalid-db
handle non-bolt files with a simple error screen
This commit is contained in:
commit
6b6a241245
@ -32,7 +32,6 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer termbox.Close()
|
defer termbox.Close()
|
||||||
|
|
||||||
style := defaultStyle()
|
style := defaultStyle()
|
||||||
termbox.SetOutputMode(termbox.Output256)
|
termbox.SetOutputMode(termbox.Output256)
|
||||||
|
|
||||||
@ -41,8 +40,14 @@ func main() {
|
|||||||
currentFilename = databaseFile
|
currentFilename = databaseFile
|
||||||
db, err = bolt.Open(databaseFile, 0600, nil)
|
db, err = bolt.Open(databaseFile, 0600, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error reading file: %q\n", err.Error())
|
if len(databaseFiles) > 1 {
|
||||||
os.Exit(1)
|
mainLoop(nil, style)
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
termbox.Close()
|
||||||
|
fmt.Printf("Error reading file: %q\n", err.Error())
|
||||||
|
os.Exit(111)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// First things first, load the database into memory
|
// First things first, load the database into memory
|
||||||
|
@ -454,6 +454,12 @@ func (screen *BrowserScreen) moveCursorDown() bool {
|
|||||||
func (screen *BrowserScreen) performLayout() {}
|
func (screen *BrowserScreen) performLayout() {}
|
||||||
|
|
||||||
func (screen *BrowserScreen) drawScreen(style Style) {
|
func (screen *BrowserScreen) drawScreen(style Style) {
|
||||||
|
if screen.db == nil {
|
||||||
|
screen.drawHeader(style)
|
||||||
|
screen.setMessage("Invalid DB. Press 'q' to quit, '?' for help")
|
||||||
|
screen.drawFooter(style)
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(screen.db.buckets) == 0 && screen.mode&modeInsertBucket != modeInsertBucket {
|
if len(screen.db.buckets) == 0 && screen.mode&modeInsertBucket != modeInsertBucket {
|
||||||
// Force a bucket insert
|
// Force a bucket insert
|
||||||
screen.startInsertItemAtParent(typeBucket)
|
screen.startInsertItemAtParent(typeBucket)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user