Kristian Fiskerstrand avatar Kristian Fiskerstrand committed cfb2334

First draft

Comments (0)

Files changed (1)

 
 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 @@
++++ b/sksdump.ml	Wed Nov 07 21:47:16 2012 +0100
+@@ -80,9 +80,37 @@
      let file = open_out fname in
      protect ~f:(fun () -> write_to_file size stream file)
        ~finally:(fun () -> close_out file)
--
 +  
++  let time_to_string time =
++   let tm = Unix.localtime time in
++    sprintf "%04d-%02d-%02d %02d:%02d:%02d"
++    (1900 + tm.Unix.tm_year) (1 + tm.Unix.tm_mon) tm.Unix.tm_mday
++    tm.Unix.tm_hour tm.Unix.tm_min tm.Unix.tm_sec
+ 
++
 +  let dump_database_create_metadata dumpdir name size ctr start_time =
 +   let fname = Filename.concat dumpdir (sprintf "metadata-%s.txt" name) in
++   let numkey = Keydb.get_num_keys () in
++   let c = ref 0  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);
++   output_string file (sprintf "#Metadata-for: %s\n" !Settings.hostname);
++   output_string file (sprintf "#Dump-started: %s\n" (time_to_string start_time));
++   output_string file (sprintf "#Files-Count: %d\n" ctr);
++   output_string file (sprintf "#Key-Count: %d\n" numkey);
++   output_string file (sprintf "#Checksums:\n");
++   while !c < ctr do 
++     output_string file (sprintf "%s %s-%04d.pgp\n" (Digest.to_hex(Digest.file (Filename.concat dumpdir (sprintf "%s-%04d.pgp" name !c)))) name !c);
++     incr c
++   done;
++   output_string file (sprintf "#Dump-ended: %s\n" (time_to_string (Unix.gettimeofday())));
 +   close_out file;
 +   ()
 +  
 +    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
+       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 @@
+@@ -91,9 +119,10 @@
+         in
+         write_to_fname size stream fname;
          incr ctr
-       done
+-      done
++      done;
++      dump_database_create_metadata dumpdir name size !ctr start_time
      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.