versioner.go 938 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (C) 2014 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. // Package versioner implements common interfaces for file versioning and a
  7. // simple default versioning scheme.
  8. package versioner
  9. import (
  10. "time"
  11. "github.com/syncthing/syncthing/lib/fs"
  12. )
  13. type Versioner interface {
  14. Archive(filePath string) error
  15. }
  16. type FileVersion struct {
  17. VersionTime time.Time `json:"versionTime"`
  18. ModTime time.Time `json:"modTime"`
  19. Size int64 `json:"size"`
  20. }
  21. var Factories = map[string]func(folderID string, filesystem fs.Filesystem, params map[string]string) Versioner{}
  22. const (
  23. TimeFormat = "20060102-150405"
  24. TimeGlob = "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]" // glob pattern matching TimeFormat
  25. )