lib/versioner: Use mtime for version cleanup (fixes #5765) (#5769)

This commit is contained in:
Audrius Butkevicius
2019-06-11 08:16:55 +01:00
committed by Jakob Borg
parent b7c70a9817
commit 21f50e2f8f
6 changed files with 99 additions and 87 deletions

View File

@@ -36,16 +36,6 @@ import (
"github.com/thejerf/suture"
)
var locationLocal *time.Location
func init() {
var err error
locationLocal, err = time.LoadLocation("Local")
if err != nil {
panic(err.Error())
}
}
// How many files to send in each Index/IndexUpdate message.
const (
maxBatchSizeBytes = 250 * 1024 // Aim for making index messages no larger than 250 KiB (uncompressed)

View File

@@ -2852,7 +2852,7 @@ func TestVersionRestore(t *testing.T) {
defer cleanupModel(m)
m.ScanFolder("default")
sentinel, err := time.ParseInLocation(versioner.TimeFormat, "20200101-010101", locationLocal)
sentinel, err := time.ParseInLocation(versioner.TimeFormat, "20200101-010101", time.Local)
must(t, err)
sentinelTag := sentinel.Format(versioner.TimeFormat)
@@ -2926,7 +2926,7 @@ func TestVersionRestore(t *testing.T) {
}
makeTime := func(s string) time.Time {
tm, err := time.ParseInLocation(versioner.TimeFormat, s, locationLocal)
tm, err := time.ParseInLocation(versioner.TimeFormat, s, time.Local)
if err != nil {
t.Error(err)
}
@@ -2960,7 +2960,7 @@ func TestVersionRestore(t *testing.T) {
if runtime.GOOS == "windows" {
file = filepath.FromSlash(file)
}
tag := version.In(locationLocal).Truncate(time.Second).Format(versioner.TimeFormat)
tag := version.In(time.Local).Truncate(time.Second).Format(versioner.TimeFormat)
taggedName := filepath.Join(".stversions", versioner.TagFilename(file, tag))
fd, err := filesystem.Open(file)
if err != nil {