chore(db): remove unused function

Remove the function that sets the path to the (no longer supported)
default database file.
This commit is contained in:
Dan Anglin 2023-12-12 13:04:50 +00:00
parent fc5fa7b0ca
commit 0326fce1e7
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638
2 changed files with 1 additions and 37 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/test/databases/*.db
/pelican
/kanban.pelican

View file

@ -6,7 +6,6 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strconv"
"time"
@ -28,8 +27,6 @@ type BoltItem interface {
func OpenDatabase(path string) (*bolt.DB, error) {
var err error
path = dbPath(path)
if err = mkDataDir(path); err != nil {
return nil, fmt.Errorf("unable to make the data directory, %w", err)
}
@ -243,40 +240,6 @@ func Delete(db *bolt.DB, bucketName string, itemID int) error {
return nil
}
// dbPath returns the path to the database file. If a path is given then that is returned. Otherwise the default path is returned.
// For linux, the default location of the database file is $XDG_DATA_HOME/canal/canal.db. If the XDG_DATA_HOME environment
// variable is not set then it will default to $HOME/.local/share/canal/canal.db. For all other operating systems the default
// location is $HOME/.canal/canal.db.
func dbPath(path string) string {
if len(path) > 0 {
filepath.Dir(path)
return path
}
dbFilename := "pelican.db"
var dataDir string
goos := runtime.GOOS
switch goos {
case "linux":
dataHome := os.Getenv("XDG_DATA_HOME")
if len(dataHome) == 0 {
dataHome = filepath.Join(os.Getenv("HOME"), ".local", "share")
}
dataDir = filepath.Join(dataHome, "pelican")
default:
dataDir = filepath.Join(os.Getenv("HOME"), ".pelican")
}
path = filepath.Join(dataDir, dbFilename)
return path
}
// mkDataDir creates the data directory of a given path to the database.
func mkDataDir(path string) error {
dir := filepath.Dir(path)