aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaëtan Gilbert2020-04-28 13:22:11 +0200
committerGaëtan Gilbert2020-04-28 13:24:44 +0200
commit1f33314961ad955e6ed5314a499089f3138dfe69 (patch)
tree1796230d615023af1096cfd2ef73c2df07358463
parent25c7e0cb30a7e196a293df9620bc4b801eaafa27 (diff)
Close files in fetch_delayed
Close #12192 Also removed transforming arbitrary exceptions into Faulty to make it easier to reason about exception flow
-rw-r--r--vernac/library.ml22
1 files changed, 13 insertions, 9 deletions
diff --git a/vernac/library.ml b/vernac/library.ml
index 35b2a18871..5fddaa759b 100644
--- a/vernac/library.ml
+++ b/vernac/library.ml
@@ -57,14 +57,18 @@ let in_delayed f ch ~segment =
let fetch_delayed del =
let { del_digest = digest; del_file = f; del_off = pos; } = del in
- try
- let ch = open_in_bin f in
- let () = LargeFile.seek_in ch pos in
- let obj = System.marshal_in f ch in
- let digest' = Digest.input ch in
- if not (String.equal digest digest') then raise (Faulty f);
- obj
- with e when CErrors.noncritical e -> raise (Faulty f)
+ let ch = open_in_bin f in
+ let obj, digest' =
+ try
+ let () = LargeFile.seek_in ch pos in
+ let obj = System.marshal_in f ch in
+ let digest' = Digest.input ch in
+ obj, digest'
+ with e -> close_in ch; raise e
+ in
+ close_in ch;
+ if not (String.equal digest digest') then raise (Faulty f);
+ obj
end
@@ -200,7 +204,7 @@ let access_table what tables dp i =
with Faulty f ->
user_err ~hdr:"Library.access_table"
(str "The file " ++ str f ++ str " (bound to " ++ str dir_path ++
- str ") is inaccessible or corrupted,\ncannot load some " ++
+ str ") is corrupted,\ncannot load some " ++
str what ++ str " in it.\n")
in
tables := DPmap.add dp (Fetched t) !tables;