Skip to content

Commit 60cd0d7

Browse files
committed
minor cleanup
1 parent 7d86579 commit 60cd0d7

3 files changed

Lines changed: 5 additions & 42 deletions

File tree

cmd/daemon/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
}
4949
// TODO: These paths should be probably defined in a package
5050
pidFile := filepath.Join(dataDir, "daemon.pid")
51-
reshHistoryPath := filepath.Join(dataDir, "history.reshjson")
51+
reshHistoryPath := filepath.Join(dataDir, datadir.HistoryFileName)
5252
bashHistoryPath := filepath.Join(homeDir, ".bash_history")
5353
zshHistoryPath := filepath.Join(homeDir, ".zsh_history")
5454
deviceID, err := device.GetID(dataDir)

cmd/install-utils/migrate.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ func migrateHistoryLocation(out *output.Output) error {
102102
if err != nil {
103103
return fmt.Errorf("failed to get data directory: %w", err)
104104
}
105-
// TODO: de-hardcode this
106-
historyPath := path.Join(dataDir, "history.reshjson")
105+
historyPath := path.Join(dataDir, datadir.HistoryFileName)
107106

108107
exists, err := futil.FileExists(historyPath)
109108
if err != nil {
@@ -149,8 +148,7 @@ func migrateHistoryFormat(out *output.Output) error {
149148
if err != nil {
150149
return fmt.Errorf("could not get user data directory: %w", err)
151150
}
152-
// TODO: de-hardcode this
153-
historyPath := path.Join(dataDir, "history.reshjson")
151+
historyPath := path.Join(dataDir, datadir.HistoryFileName)
154152

155153
exists, err := futil.FileExists(historyPath)
156154
if err != nil {

internal/datadir/datadir.go

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,8 @@ import (
66
"path"
77
)
88

9-
// You should not need this caching
10-
// It messes with proper dependency injection
11-
// Find another way
12-
13-
// type dirCache struct {
14-
// dir string
15-
// err error
16-
//
17-
// cached bool
18-
// }
19-
//
20-
// var cache dirCache
21-
//
22-
// func getPathNoCache() (string, error) {
23-
// reshDir := "resh"
24-
// xdgDir, found := os.LookupEnv("XDG_DATA_HOME")
25-
// if found {
26-
// return path.Join(xdgDir, reshDir), nil
27-
// }
28-
// homeDir, err := os.UserHomeDir()
29-
// if err != nil {
30-
// return "", fmt.Errorf("error while getting home dir: %w", err)
31-
// }
32-
// return path.Join(homeDir, ".local/share/", reshDir), nil
33-
// }
34-
//
35-
// func GetPath() (string, error) {
36-
// if !cache.cached {
37-
// dir, err := getPathNoCache()
38-
// cache = dirCache{
39-
// dir: dir,
40-
// err: err,
41-
// cached: true,
42-
// }
43-
// }
44-
// return cache.dir, cache.err
45-
// }
9+
// Maybe there is a better place for this constant
10+
const HistoryFileName = "history.reshjson"
4611

4712
func GetPath() (string, error) {
4813
reshDir := "resh"

0 commit comments

Comments
 (0)