Skip to content

Commit f7af6c2

Browse files
committed
feat: Adds LastModifiedOrErr to expose error for LastModified (#26623)
(cherry picked from commit 0f57087)
1 parent 1e4693a commit f7af6c2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tsdb/shard.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,19 @@ func (s *Shard) ready() error {
606606
}
607607

608608
// LastModified returns the time when this shard was last modified.
609+
// On error and 0 TSM files this will return time.Time{} (0001-01-01 00:00:00 +0000 UTC)
609610
func (s *Shard) LastModified() time.Time {
611+
t, _ := s.LastModifiedWithErr()
612+
return t
613+
}
614+
615+
// LastModifiedOrErr returns the time when this shard was last modified and an error.
616+
func (s *Shard) LastModifiedWithErr() (time.Time, error) {
610617
engine, err := s.Engine()
611618
if err != nil {
612-
return time.Time{}
619+
return time.Time{}, err
613620
}
614-
return engine.LastModified()
621+
return engine.LastModified(), nil
615622
}
616623

617624
// Index returns a reference to the underlying index. It returns an error if

0 commit comments

Comments
 (0)