Skip to content

Commit 3083d28

Browse files
authored
Merge pull request #5942 from apache/nouveau-ken
restore nouveau_index_updater:outdated
2 parents 322e55c + b58a68a commit 3083d28

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/nouveau/src/nouveau_index_updater.erl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
-include("nouveau.hrl").
1919

2020
%% public api
21-
-export([get_db_info/1]).
21+
-export([outdated/1, get_db_info/1]).
2222

2323
%% callbacks
2424
-export([update/1]).
@@ -47,6 +47,21 @@
4747
batch
4848
}).
4949

50+
outdated(#index{} = Index) ->
51+
{ok, Db} = couch_db:open_int(Index#index.dbname, []),
52+
try
53+
case open_or_create_index(Db, Index) of
54+
{ok, #{} = Info} ->
55+
#{<<"update_seq">> := IndexUpdateSeq, <<"purge_seq">> := IndexPurgeSeq} = Info,
56+
{DbUpdateSeq, DbPurgeSeq} = get_db_info(Db),
57+
DbUpdateSeq > IndexUpdateSeq orelse DbPurgeSeq > IndexPurgeSeq;
58+
{error, Reason} ->
59+
{error, Reason}
60+
end
61+
after
62+
couch_db:close(Db)
63+
end.
64+
5065
update(#index{} = Index) ->
5166
{ok, Db} = couch_db:open_int(Index#index.dbname, []),
5267
try
@@ -219,12 +234,14 @@ open_or_create_index(Db, #index{} = Index) ->
219234
get_db_info(#index{} = Index) ->
220235
{ok, Db} = couch_db:open_int(Index#index.dbname, []),
221236
try
222-
UpdateSeq = couch_db:get_update_seq(Db),
223-
PurgeSeq = couch_db:get_purge_seq(Db),
224-
{UpdateSeq, PurgeSeq}
237+
get_db_info(Db)
225238
after
226239
couch_db:close(Db)
227-
end.
240+
end;
241+
get_db_info(Db) ->
242+
UpdateSeq = couch_db:get_update_seq(Db),
243+
PurgeSeq = couch_db:get_purge_seq(Db),
244+
{UpdateSeq, PurgeSeq}.
228245

229246
index_definition(#index{} = Index, InitialPurgeSeq) ->
230247
#{

0 commit comments

Comments
 (0)