[Pkg-ocaml-maint-commits] r1445 - trunk/tools/dh_ocaml

Stefano Zacchiroli zack@costa.debian.org
Sat, 09 Jul 2005 16:49:50 +0000


Author: zack
Date: 2005-07-09 16:49:49 +0000 (Sat, 09 Jul 2005)
New Revision: 1445

Modified:
   trunk/tools/dh_ocaml/ocaml-md5sums.ml.in
Log:
remove md5sums dir when registry is empty on update


Modified: trunk/tools/dh_ocaml/ocaml-md5sums.ml.in
===================================================================
--- trunk/tools/dh_ocaml/ocaml-md5sums.ml.in	2005-07-09 16:49:14 UTC (rev 1444)
+++ trunk/tools/dh_ocaml/ocaml-md5sums.ml.in	2005-07-09 16:49:49 UTC (rev 1445)
@@ -4,7 +4,7 @@
  * Copyright (C) 2005, Stefano Zacchiroli <zack@debian.org>
  *
  * Created:        Wed, 06 Apr 2005 16:55:39 +0200 zack
- * Last-Modified:  Sat, 09 Jul 2005 17:40:44 +0200 zack
+ * Last-Modified:  Sat, 09 Jul 2005 18:43:03 +0200 zack
  *
  * This is free software, you can redistribute it and/or modify it under the
  * terms of the GNU General Public License version 2 as published by the Free
@@ -249,9 +249,9 @@
 let update () =
   info (sprintf "updating registry %s using info from %s/"
     registry_file md5sums_dir);
-  let registry = open_out registry_file in
   let keys = Hashtbl.create 1024 in (* history of seen registry keys *)
   let dir = Unix.opendir md5sums_dir in
+  let registry = open_out registry_file in
   try
     while true do
       let fname = sprintf "%s/%s" md5sums_dir (Unix.readdir dir) in
@@ -271,7 +271,10 @@
   with End_of_file ->
     Unix.closedir dir;
     close_out registry;
-    if is_empty registry_file then Sys.remove registry_file
+    if is_empty registry_file then begin
+      Sys.remove registry_file;
+      ignore (Sys.command ("/bin/rmdir -p " ^ md5sums_dir))
+    end
 
 (** {2 Main} *)