diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-12 20:14:47 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-12 20:14:47 +0200 |
| commit | 3f8679be9373ee7508d512dfdfc1dda0839c7f90 (patch) | |
| tree | ec02eb075f6c4e90f21baa2fe674e86a2f7f6a62 /internal/config | |
| parent | 24a84671ace373ae331fa83a1ff484990f4dff0e (diff) | |
| download | krino-3f8679be9373ee7508d512dfdfc1dda0839c7f90.tar.gz krino-3f8679be9373ee7508d512dfdfc1dda0839c7f90.zip | |
krino: acting — trash, journal, apply, lock, review, undo
Diffstat (limited to 'internal/config')
| -rw-r--r-- | internal/config/load.go | 6 | ||||
| -rw-r--r-- | internal/config/load_test.go | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/internal/config/load.go b/internal/config/load.go index f6eaeae..cd4d97c 100644 --- a/internal/config/load.go +++ b/internal/config/load.go @@ -91,3 +91,9 @@ func (c *Config) LogFile() string { } return filepath.Join(xdg.StateHome(), "krino", "krino.log") } + +// LockFile is where a directory's lock lives while a run is active: +// $XDG_STATE_HOME/krino/<name>.lock, beside the log (spec §3). +func (c *Config) LockFile(name string) string { + return filepath.Join(xdg.StateHome(), "krino", name+".lock") +} diff --git a/internal/config/load_test.go b/internal/config/load_test.go index be72fc0..1cc3ac9 100644 --- a/internal/config/load_test.go +++ b/internal/config/load_test.go @@ -104,3 +104,14 @@ func TestDefaultFileAndLogFile(t *testing.T) { t.Errorf("LogFile() = %q", got) } } + +func TestLockFile(t *testing.T) { + h := t.TempDir() + t.Setenv("HOME", h) + t.Setenv("XDG_STATE_HOME", "") + c := &Config{} + want := filepath.Join(h, ".local", "state", "krino", "dl.lock") + if got := c.LockFile("dl"); got != want { + t.Errorf("LockFile = %q, want %q", got, want) + } +} |
