Skip to content

Commit

Permalink
feat: update db path to be ~/.config/oolong/oolong.db
Browse files Browse the repository at this point in the history
should create the dir if it doesn't exist
  • Loading branch information
JackWilli committed Dec 8, 2024
1 parent 79d7b02 commit 77334ed
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/db/db.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package db

import (
"os"
"path/filepath"

"go.etcd.io/bbolt"
)

var Database *bbolt.DB

const PinnedBucket = "PinnedNotes"
const db_path = "pinned_notes.db"

// Initialize the database and ensure the bucket exists
func InitializeDB() error {
var err error
homeDir, err := os.UserHomeDir()
if err != nil {
return err
}

db_path := filepath.Join(homeDir, ".config", "oolong", "oolong.db")

err = os.MkdirAll(filepath.Dir(db_path), 0755)
if err != nil {
return err
}

Database, err = bbolt.Open(db_path, 0666, nil)
if err != nil {
return err
Expand Down

0 comments on commit 77334ed

Please sign in to comment.