File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -233,10 +233,12 @@ def snapshot_by_id(self, snapshot_id: int) -> Optional[Snapshot]:
233
233
def latest_snapshot_before_timestamp (self , timestamp_ms : int ) -> Optional [Snapshot ]:
234
234
"""Get the snapshot right before the given timestamp."""
235
235
result , prev_timestamp = None , 0
236
- for snapshot in self .snapshots :
237
- if prev_timestamp < snapshot .timestamp_ms < timestamp_ms :
238
- result , prev_timestamp = snapshot , snapshot .timestamp_ms
239
- return result if result else None
236
+ if self .current_snapshot_id is not None :
237
+ for snapshot_id , snapshot_timestamp in self .ancestors_of (self .current_snapshot_id ):
238
+ snapshot = self .snapshot_by_id (snapshot_id )
239
+ if prev_timestamp < snapshot_timestamp < timestamp_ms :
240
+ result , prev_timestamp = snapshot , snapshot_timestamp
241
+ return result
240
242
241
243
def ancestors_of (self , snapshot_id : int ) -> List [tuple [int , int ]]:
242
244
"""Get the snapshot_id of the ancestors of the given snapshot."""
You can’t perform that action at this time.
0 commit comments