sanity check the startup directory
This commit is contained in:
15
gui.go
15
gui.go
@ -38,8 +38,9 @@ func NewGUI() *GUI {
|
||||
|
||||
// Start launches a new syndie-gui application
|
||||
func (client *GUI) Start(path string) {
|
||||
sanityCheckStartupDir(path)
|
||||
client.db = newDatabase()
|
||||
client.db.openDB(path)
|
||||
client.db.openDB(path + "/db/bolt.db")
|
||||
client.db.reload()
|
||||
|
||||
a := app.New()
|
||||
@ -98,3 +99,15 @@ func (client *GUI) fetch(fetch bool) {
|
||||
func (client *GUI) applyOptions() {
|
||||
client.pagination = 25
|
||||
}
|
||||
|
||||
func sanityCheckStartupDir(path string) {
|
||||
var err error
|
||||
_, err = os.Stat(path)
|
||||
if os.IsNotExist(err) {
|
||||
os.Mkdir(path, 0777)
|
||||
_, err = os.Stat(path + "/db/")
|
||||
if os.IsNotExist(err) {
|
||||
os.Mkdir(path+"/db/", 0777)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user