Kristian Fiskerstrand avatar Kristian Fiskerstrand committed 3c75386

[mq]: ExpiryCleanup

Comments (0)

Files changed (2)

   sprintf "uid:%s:%s:%s:"
     uid_string (time_to_string ctime) (time_to_string exptime)
 
+let get_latest_exp_time l =
+   List.fold_left ~init:(None,None) ~f:(fun (cmax,emax) (cr,ex) ->
+      if cr > cmax then (cr, ex) else (cmax, emax)) l
+
 let get_key_expiration_from_uid keyid sigs =
   let sigs = get_self_sigs keyid sigs in
   let times = List.map ~f:ParsePGP.get_key_exptimes sigs in
   let (ctime,exptime) =
-    List.fold_left ~init:(None,None) ~f:(fun (cmax,emax) (cr,ex) ->
-      if cr > cmax then (cr, ex) else (cmax, emax)) times in
+    get_latest_exp_time times in
   (ctime,exptime)
 
 let key_expiration_from_uids keyid pk_ctime uids =
         | _ -> (None, None)
       ) uids in
   let (ctime, exptime) =
-     List.fold_left ~init:(None,None) ~f:(fun (cmax,emax) (cr,ex) ->
-       if cr > cmax then (cr, ex) else (cmax, emax)) expir
+     get_latest_exp_time expir
   in
   match exptime with
    | Some x -> Int64.add x pk_ctime
     | Some days -> sprintf "%Ld"
         (Int64.add pki.pk_ctime (Int64.mul daysecs (Int64.of_int days)))
   in
-  let key_expiry = key_expiration_from_uids full_keyid pki.pk_ctime uids
-  in
-    let key_expiry_string = if Int64.to_int key_expiry = 0
+  let key_expiry = key_expiration_from_uids full_keyid pki.pk_ctime uids in
+  let key_expiry_string = if Int64.to_int key_expiry = 0
       then exp_string else sprintf "%Ld" key_expiry
   in
   let key_line = sprintf "pub:%s:%d:%d:%Ld:%s:%s"
                   (ctime,exptime)
              )
       in
-      match (ctime,exptime_delta) with
-        | (Some x,None) -> (Some x,None)
-        | (None,_) -> (None,None)
-        | (Some x,Some y) -> (Some x,Some y)
+      match exptime_delta with
+        | None -> (None,None)
+        | Some _ -> (ctime,exptime_delta)
 
 
 let get_times sign = match sign with
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.