Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
969b3c1703 |
@@ -28,8 +28,8 @@ the tag exists and is exercised; what is left is merging `next` to
|
|||||||
parser picked out the parts it recognised and skipped the rest, so
|
parser picked out the parts it recognised and skipped the rest, so
|
||||||
`1.0y` became zero and `--prune --keep-newer-than 1.0y` deleted every
|
`1.0y` became zero and `--prune --keep-newer-than 1.0y` deleted every
|
||||||
snapshot of the backed-up names, the new one included. `1.0y`,
|
snapshot of the backed-up names, the new one included. `1.0y`,
|
||||||
`1,5y`, `30 days` and `x7d` are now errors; decimals still work in Go
|
`1,5y`, `30 days`, `x7d` and a bare `0` are now errors; decimals still
|
||||||
units such as `1.5h`.
|
work in Go units such as `1.5h`.
|
||||||
|
|
||||||
- 2026-10-06: Made a backup re-chunk a known file that lists a chunk no
|
- 2026-10-06: Made a backup re-chunk a known file that lists a chunk no
|
||||||
uploaded blob holds
|
uploaded blob holds
|
||||||
|
|||||||
@@ -149,6 +149,13 @@ func parseDuration(s string) (time.Duration, error) {
|
|||||||
return 0, errNegativeDuration
|
return 0, errNegativeDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A bare number has no unit, but time.ParseDuration accepts 0, which
|
||||||
|
// would put the cutoff at now and select every snapshot.
|
||||||
|
_, err := strconv.ParseFloat(s, 64)
|
||||||
|
if err == nil {
|
||||||
|
return 0, fmt.Errorf("%w: %q", errInvalidDuration, s)
|
||||||
|
}
|
||||||
|
|
||||||
d, err := time.ParseDuration(s)
|
d, err := time.ParseDuration(s)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return d, nil
|
return d, nil
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ func TestParseDuration(t *testing.T) {
|
|||||||
{"1y6mo", 365*24*time.Hour + 180*24*time.Hour, false},
|
{"1y6mo", 365*24*time.Hour + 180*24*time.Hour, false},
|
||||||
// Rejected inputs.
|
// Rejected inputs.
|
||||||
{"6", 0, true}, // bare number, no unit
|
{"6", 0, true}, // bare number, no unit
|
||||||
|
{"0", 0, true}, // bare number; time.ParseDuration accepts it
|
||||||
|
{"+0", 0, true}, // bare number; time.ParseDuration accepts it
|
||||||
{"5x", 0, true}, // unknown unit
|
{"5x", 0, true}, // unknown unit
|
||||||
{"-5d", 0, true}, // negative, extended unit
|
{"-5d", 0, true}, // negative, extended unit
|
||||||
{"-5h", 0, true}, // negative, Go unit
|
{"-5h", 0, true}, // negative, Go unit
|
||||||
|
|||||||
Reference in New Issue
Block a user