Skip to content

Commit

Permalink
Reset state on recovery if no item files
Browse files Browse the repository at this point in the history
Whether or not there are zero valid item files
  • Loading branch information
jfcloutier committed Jan 31, 2022
1 parent 96aaf8b commit 308b259
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/jackalope/persistent_work_list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,12 @@ defmodule Jackalope.PersistentWorkList do

delta_time = Expiration.now() - latest_time(state)

expirations =
item_files =
File.ls!(state.data_dir)
|> Enum.filter(&Regex.match?(~r/.*\.item/, &1))

expirations =
item_files
|> Enum.reduce(
[],
fn item_file, acc ->
Expand All @@ -408,7 +411,7 @@ defmodule Jackalope.PersistentWorkList do

item_indices = Map.keys(expirations)

if Enum.empty?(item_indices) do
if Enum.empty?(item_files) do
reset_state(state)
else
bottom_index = Enum.min(item_indices)
Expand Down

0 comments on commit 308b259

Please sign in to comment.