Commit 9dd16701 authored by Stephane Glondu's avatar Stephane Glondu

Avoid error 500 in election_pretty_ballots when no ballots have been cast

parent c52aa818
......@@ -326,10 +326,13 @@ let get_ballot_hashes uuid =
StringMap.bindings ballots |> List.map fst |> return
| _ ->
let uuid_s = raw_string_of_uuid uuid in
let ballots = Lwt_unix.files_of_directory (!Web_config.spool_dir / uuid_s / "ballots") in
let%lwt ballots = Lwt_stream.to_list ballots in
let ballots = List.filter (fun x -> x <> "." && x <> "..") ballots in
return (List.rev_map unurlize ballots)
try%lwt
let ballots = Lwt_unix.files_of_directory (!Web_config.spool_dir / uuid_s / "ballots") in
let%lwt ballots = Lwt_stream.to_list ballots in
let ballots = List.filter (fun x -> x <> "." && x <> "..") ballots in
return (List.rev_map unurlize ballots)
with Unix.Unix_error(Unix.ENOENT, "opendir", _) ->
return []
let get_ballot_by_hash uuid hash =
match%lwt get_election_state uuid with
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment