summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 22:32:35 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-15 22:32:35 +0200
commit8d0a4024b76b7e85c0ccede853fc2cdcceea2afb (patch)
tree2eb5cdabd48223597bd1012758ecaddd3e4d5979 /internal
parent1a1dc05b5250c6a281736fa6b706f74721f83847 (diff)
downloadkrino-8d0a4024b76b7e85c0ccede853fc2cdcceea2afb.tar.gz
krino-8d0a4024b76b7e85c0ccede853fc2cdcceea2afb.zip
check refuses an empty time format; krino.conf(5) corrected from the re-audit
Diffstat (limited to 'internal')
-rw-r--r--internal/engine/engine_test.go2
-rw-r--r--internal/plan/placeholder.go3
2 files changed, 5 insertions, 0 deletions
diff --git a/internal/engine/engine_test.go b/internal/engine/engine_test.go
index 4af8f79..7de2f76 100644
--- a/internal/engine/engine_test.go
+++ b/internal/engine/engine_test.go
@@ -272,6 +272,8 @@ func TestLoadRefusesBadPlaceholders(t *testing.T) {
{`(rename "{0}-x")`, "numbered from 1"},
{`(copy "Out/{10}")`, "unknown placeholder {10}"},
{`(move "Out/{name")`, "unclosed placeholder"},
+ {`(move "Out/{mtime:}")`, "needs a format"},
+ {`(move "Out/{now:}")`, "needs a format"},
} {
h := sandbox(t)
os.MkdirAll(filepath.Join(h, "dl"), 0o755)
diff --git a/internal/plan/placeholder.go b/internal/plan/placeholder.go
index 5922b07..5675e01 100644
--- a/internal/plan/placeholder.go
+++ b/internal/plan/placeholder.go
@@ -143,6 +143,9 @@ func expandOne(body string, f Facts) (string, error) {
// they point at what the config author actually wrote (B3) instead of
// hardcoding "mtime" for a {now:...} format error.
func strftime(verb, format string, t time.Time) (string, error) {
+ if format == "" {
+ return "", fmt.Errorf("{%s:} needs a format, like {%s:%%Y}", verb, verb)
+ }
var b strings.Builder
for i := 0; i < len(format); i++ {
c := format[i]