Irmin_lmdb: make sure we open the file with consistent rights

This commit is contained in:
Vincent Botbol 2018-06-29 00:30:43 +02:00 committed by Benjamin Canou
parent 2830ca3232
commit 85cac4282c

View File

@ -642,7 +642,8 @@ module Make
let root = match root with None -> "irmin.ldb" | Some root -> root in let root = match root with None -> "irmin.ldb" | Some root -> root in
if not (Sys.file_exists root) then Unix.mkdir root 0o755 ; if not (Sys.file_exists root) then Unix.mkdir root 0o755 ;
let flags = Lmdb.NoTLS :: if readonly then [ Lmdb.RdOnly ] else [] in let flags = Lmdb.NoTLS :: if readonly then [ Lmdb.RdOnly ] else [] in
match Lmdb.opendir ~mapsize ~flags root 0o644 with let file_flags = if readonly then 0o444 else 0o644 in
match Lmdb.opendir ~mapsize ~flags root file_flags with
| Error err -> Lwt.fail_with (Lmdb.string_of_error err) | Error err -> Lwt.fail_with (Lmdb.string_of_error err)
| Ok db -> | Ok db ->
let db = { db ; root } in let db = { db ; root } in