Basic client and server apps. #41
@ -1,27 +1,11 @@
|
|||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"bunker/commons"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *database) configureDBPath() error {
|
func (d *database) configureDBPath() error {
|
||||||
rootDir, err := os.UserConfigDir()
|
d.dbPath = filepath.Join(d.app.Fyne().Storage().RootURI().Path(), "database.sqlite3")
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("configure DB path: get config dir: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
rootDir = filepath.Join(rootDir, commons.ClientAppID)
|
|
||||||
|
|
||||||
//nolint:mnd
|
|
||||||
if err := os.MkdirAll(rootDir, 0o700); err != nil {
|
|
||||||
return fmt.Errorf("configure DB path: create dir: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
d.dbPath = filepath.Join(rootDir, "database.sqlite3")
|
|
||||||
|
|
||||||
d.logger.Info("Database path configured.", "path", d.dbPath)
|
d.logger.Info("Database path configured.", "path", d.dbPath)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user