summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/index.erl11
-rw-r--r--src/storage.erl11
2 files changed, 13 insertions, 9 deletions
diff --git a/src/index.erl b/src/index.erl
index bbc9a10..c1e0352 100644
--- a/src/index.erl
+++ b/src/index.erl
@@ -77,6 +77,17 @@ decodedata(<<_:?ENTRYSIZE/binary-unit:16, _>>, _Acc) ->
util:exit_with_error(badformat, readindex,
"Index line not ending with linefeed").
+-spec size(string()) -> integer().
+size(Basepath) ->
+ case file:open(Basepath, [read, binary]) of
+ {ok, File} ->
+ {ok, Filesize} = file:position(File, eof),
+ Filesize mod ?ENTRYSIZEINFILE;
+ {error, Error} ->
+ util:exit_with_error(Error, readfile,
+ "Error opening file for reading")
+ end.
+
-spec get(string(), integer()) -> binary().
get(Basepath, Index) ->
case getrange(Basepath, Index, Index) of
diff --git a/src/storage.erl b/src/storage.erl
index e09acdb..df6641a 100644
--- a/src/storage.erl
+++ b/src/storage.erl
@@ -43,15 +43,8 @@ request(get, "ct/storage/fetchnewentries", _Input) ->
{entries, Entries}]}).
fetchnewhashes(Index) ->
- lists:reverse(fetchnewhashes(Index, [])).
-
-fetchnewhashes(Index, Acc) ->
- case index:get(newentries_path(), Index) of
- noentry ->
- Acc;
- Entry ->
- fetchnewhashes(Index + 1, [Entry | Acc])
- end.
+ Size = index:size(newentries_path()),
+ index:getrange(newentries_path(), Index, Size - 1).
%% Private functions.
html(Text, Input) ->