Skip to content

Commit 0f57087

Browse files
authored
feat: Adds LastModifiedOrErr to expose error for LastModified (#26623)
1 parent 4e8a3b3 commit 0f57087

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
@@ -459,12 +459,19 @@ func (s *Shard) ready() error {
459459
}
460460

461461
// LastModified returns the time when this shard was last modified.
462+
// On error and 0 TSM files this will return time.Time{} (0001-01-01 00:00:00 +0000 UTC)
462463
func (s *Shard) LastModified() time.Time {
464+
t, _ := s.LastModifiedWithErr()
465+
return t
466+
}
467+
468+
// LastModifiedOrErr returns the time when this shard was last modified and an error.
469+
func (s *Shard) LastModifiedWithErr() (time.Time, error) {
463470
engine, err := s.Engine()
464471
if err != nil {
465-
return time.Time{}
472+
return time.Time{}, err
466473
}
467-
return engine.LastModified()
474+
return engine.LastModified(), nil
468475
}
469476

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

0 commit comments

Comments
 (0)