sks-keyserver-patches / DUMP_METADATA

# HG changeset patch
# Parent 3c75386bc7ce409eca4a4629b4b14b252a8808e8
Add metadata to dump

diff -r 3c75386bc7ce sksdump.ml
--- a/sksdump.ml	Sat Oct 27 23:15:53 2012 +0200
+++ b/sksdump.ml	Wed Nov 07 20:55:16 2012 +0100
@@ -80,11 +80,24 @@
     let file = open_out fname in
     protect ~f:(fun () -> write_to_file size stream file)
       ~finally:(fun () -> close_out file)
-
+  
+  let dump_database_create_metadata dumpdir name size ctr start_time =
+   let fname = Filename.concat dumpdir (sprintf "metadata-%s.txt" name) in
+   let file = open_out fname in
+   output_string file (sprintf "Metadata for %s\n" !Settings.hostname);
+   output_string file (sprintf "Dump started: %f\n" start_time);
+   output_string file (sprintf "Dump ended: %f\n" (Unix.gettimeofday()));
+   output_string file (sprintf "Number of files: %d\n" ctr);
+   close_out file;
+   ()
+  
   let dump_database dumpdir size name =
     let (stream,close) = Keydb.create_hash_skey_stream () in
+    let start_time = Unix.gettimeofday() in
+    let () = if not (Sys.file_exists dumpdir) then
+               Unix.mkdir dumpdir  0o700; in
+    let ctr = ref 0 in
     let run () =
-      let ctr = ref 0 in
       while SStream.peek stream <> None do
         let fname =
           Filename.concat dumpdir (sprintf "%s-%04d.pgp" name !ctr)
@@ -93,7 +106,8 @@
         incr ctr
       done
     in
-    protect ~f:run ~finally:close
+     dump_database_create_metadata dumpdir name size !ctr start_time;
+     protect ~f:run ~finally:close
 
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.