diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-12-25 11:58:47 -0500 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-12-25 11:58:47 -0500 |
commit | b64cce52d9011d9c85bc68041e998f2a0c513867 (patch) | |
tree | 1b6bdccc39e06579f9471497d8ae0ce291b5687f | |
parent | 28386eb5f6c57b724c203b6043b211db36fc6c41 (diff) |
db: add `defaultDBPath`
For storing the default db path. The `dbPath` gets changed during
tests. The `defaultDBPath` can be used to reset `dbPath` back to the
default db path through the `resetDBPath` function.
-rw-r--r-- | db/db.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -14,6 +14,7 @@ import ( ) var dbPath string +var defaultDBPath string // Contains information about list of media that where already // download for different feeds. @@ -34,8 +35,8 @@ func init() { if err != nil { return } - dbPath = path.Join(h, ".config", "fern", "db.json") - + defaultDBPath = path.Join(h, ".config", "fern", "db.json") + dbPath = defaultDBPath } // Reads the fern db from disk and unmarshals it into a FernDB @@ -140,3 +141,9 @@ func (fdb *FernDB) Write() error { } return nil } + +// Sets DB path to the default path. This function is meant to be used +// by tests. +func resetDBPath() { + dbPath = defaultDBPath +} |