From 12e7928b2ce2113d5ac43d453026d0443f58c5e4 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Thu, 26 Dec 2002 19:57:46 +0000 Subject: [PATCH] - clear also .db db files - added #close method --- helm/http_getter/http_getter_map.ml | 14 +++++++++++--- helm/http_getter/http_getter_map.mli | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/helm/http_getter/http_getter_map.ml b/helm/http_getter/http_getter_map.ml index 7a5ed1a3b..26daa21d5 100644 --- a/helm/http_getter/http_getter_map.ml +++ b/helm/http_getter/http_getter_map.ml @@ -40,7 +40,7 @@ class map dbname = val mutable db = open_dbm () - initializer Gc.finalise Dbm.close db (* close db on GC *) + (*initializer Gc.finalise Dbm.close db (* close db on GC *)*) method add key value = self#doWriter (lazy ( @@ -75,10 +75,18 @@ class map dbname = method clear = self#doWriter (lazy ( Dbm.close db; - Sys.remove (dbname ^ ".dir"); - Sys.remove (dbname ^ ".pag"); + List.iter + (fun ext -> + let file = dbname ^ ext in + if Sys.file_exists file then Sys.remove file) + [".dir"; ".pag"; ".db"]; db <- open_dbm () )) + method close = + self#doWriter (lazy ( + Dbm.close db + )) + end diff --git a/helm/http_getter/http_getter_map.mli b/helm/http_getter/http_getter_map.mli index 3e0cd0878..b0725b8de 100644 --- a/helm/http_getter/http_getter_map.mli +++ b/helm/http_getter/http_getter_map.mli @@ -36,4 +36,6 @@ class map: method iter: (string -> string -> unit) -> unit method sync: unit method clear: unit + + method close: unit (* use with caution! *) end -- 2.39.2