MCPcopy
hub / github.com/kopia/kopia / createSnapshotTimeFilter

Function createSnapshotTimeFilter

cli/command_restore.go:525–546  ·  view source on GitHub ↗
(timespec string)

Source from the content-addressed store, hash-verified

523}
524
525func createSnapshotTimeFilter(timespec string) (func(*snapshot.Manifest, int, int) bool, error) {
526 if timespec == "" || timespec == "latest" {
527 return func(_ *snapshot.Manifest, i, _ int) bool {
528 return i == 0
529 }, nil
530 }
531
532 if timespec == "oldest" {
533 return func(_ *snapshot.Manifest, i, total int) bool {
534 return i == total-1
535 }, nil
536 }
537
538 t, err := computeMaxTime(timespec)
539 if err != nil {
540 return nil, err
541 }
542
543 return func(m *snapshot.Manifest, _, _ int) bool {
544 return m.StartTime.ToTime().Before(t)
545 }, nil
546}
547
548var timeAgoRE = regexp.MustCompile(`^(?:(\d{1,3})(?:y|year|years)-)?(?:(\d{1,3})(?:m|mo|month|months)-)?(?:(\d{1,3})(?:d|day|days)-)?ago$`)
549

Callers 2

tryToConvertPathToIDMethod · 0.85

Calls 3

computeMaxTimeFunction · 0.85
ToTimeMethod · 0.80
BeforeMethod · 0.45

Tested by 1