From 0326fce1e7e2e195b7dad93b179ee26d6958fcfc Mon Sep 17 00:00:00 2001 From: Dan Anglin Date: Tue, 12 Dec 2023 13:04:50 +0000 Subject: [PATCH] chore(db): remove unused function Remove the function that sets the path to the (no longer supported) default database file. --- .gitignore | 1 + internal/db/database.go | 37 ------------------------------------- 2 files changed, 1 insertion(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index a8ad0d7..63dfbf8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /test/databases/*.db /pelican +/kanban.pelican diff --git a/internal/db/database.go b/internal/db/database.go index ab2c32a..6f54980 100644 --- a/internal/db/database.go +++ b/internal/db/database.go @@ -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)