Skip to content

Commit

Permalink
Always check if a cache entry isn't None before slicing it
Browse files Browse the repository at this point in the history
Signed-off-by: Alexis Jeandet <[email protected]>
  • Loading branch information
jeandet committed Apr 17, 2024
1 parent 0462597 commit 79e1429
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions speasy/core/cache/_providers_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ def wrapped(wrapped_self, product, start_time, stop_time, **kwargs):
if len(data_chunks):
if len(data_chunks) == 1:
return data_chunks[0][dt_range.start_time:dt_range.stop_time].copy()
data_chunks[0] = data_chunks[0][dt_range.start_time:]
data_chunks[-1] = data_chunks[-1][:dt_range.stop_time]
if data_chunks[0] is not None:
data_chunks[0] = data_chunks[0][dt_range.start_time:]
if data_chunks[-1] is not None:
data_chunks[-1] = data_chunks[-1][:dt_range.stop_time]
return merge_variables(data_chunks)[dt_range.start_time:dt_range.stop_time]
return None

Expand Down Expand Up @@ -273,8 +275,12 @@ def wrapped(wrapped_self, product, start_time, stop_time, **kwargs):

if len(data_chunks):
if len(data_chunks) == 1:
return data_chunks[0][dt_range.start_time:dt_range.stop_time].copy()
data_chunks[0] = data_chunks[0][dt_range.start_time:]
if data_chunks[0] is not None:
return data_chunks[0][dt_range.start_time:dt_range.stop_time].copy()
else:
return None
if data_chunks[0] is not None:
data_chunks[0] = data_chunks[0][dt_range.start_time:]
if data_chunks[-1] is not None:
data_chunks[-1] = data_chunks[-1][:dt_range.stop_time]
return merge_variables(data_chunks)[dt_range.start_time:dt_range.stop_time]
Expand Down

0 comments on commit 79e1429

Please sign in to comment.