hotfix(storage): JSON provider versioning safety

This commit is contained in:
Quentin McGaw
2022-05-28 22:43:54 +00:00
parent 90dd3b1b5c
commit b345368257
3 changed files with 30 additions and 23 deletions

View File

@@ -1,21 +1,12 @@
package storage
import (
"strconv"
"time"
"github.com/qdm12/gluetun/internal/constants/providers"
"github.com/qdm12/gluetun/internal/models"
)
func (s *Storage) logVersionDiff(provider string, hardcodedVersion, persistedVersion uint16) {
message := provider + " servers from file discarded because they have version " +
strconv.Itoa(int(persistedVersion)) +
" and hardcoded servers have version " +
strconv.Itoa(int(hardcodedVersion))
s.logger.Info(message)
}
func (s *Storage) logTimeDiff(provider string, persistedUnix, hardcodedUnix int64) {
diff := time.Unix(persistedUnix, 0).Sub(time.Unix(hardcodedUnix, 0))
if diff < 0 {