Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 16ed5697 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Check existence of "ballots" dir before reading it

This fixes an error 500 when trying to tally when no ballots have been
cast.
parent 6bfa7c43
......@@ -324,13 +324,15 @@ let get_ballot_by_hash uuid hash =
let load_ballots uuid =
let ballots_dir = !Web_config.spool_dir / raw_string_of_uuid uuid / "ballots" in
let ballots = Lwt_unix.files_of_directory ballots_dir in
let%lwt ballots = Lwt_stream.to_list ballots in
Lwt_list.filter_map_p (fun x ->
match%lwt read_file (ballots_dir / x) with
| Some [x] -> return (Some x)
| _ -> return_none
) ballots
if%lwt Lwt_unix.file_exists ballots_dir then (
let ballots = Lwt_unix.files_of_directory ballots_dir in
let%lwt ballots = Lwt_stream.to_list ballots in
Lwt_list.filter_map_p (fun x ->
match%lwt read_file (ballots_dir / x) with
| Some [x] -> return (Some x)
| _ -> return_none
) ballots
) else return []
let dump_ballots uuid =
let%lwt ballots = load_ballots uuid in
......
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