@@ -387,6 +387,29 @@ def modified_in(file, wait):
387387# past 4+5-epsilon minutes
388388# Note: `wait` is almost 1 commit_interval shorter than forced_interval
389389# (see `do_commit()`.)
390+ def needs_timestamp (log = False ):
391+ if not autoblockchainify .config .arg .stamper_own_address :
392+ if log :
393+ logging .debug ("Timestamping by mail not configured" )
394+ return False
395+ path = autoblockchainify .config .arg .repository
396+ logfile = Path (path , 'pgp-timestamp.tmp' )
397+ sigfile = Path (path , 'pgp-timestamp.sig' )
398+ sigfile_interval = (autoblockchainify .config .arg .commit_interval
399+ * autoblockchainify .config .arg .force_after_intervals
400+ - timedelta (minutes = 4 ))
401+ if logfile .is_file () and modified_in (logfile , timedelta (minutes = 4 + 5 )):
402+ if log :
403+ logging .stop ("Logfile more recent than 4+5 minutes, skipping" )
404+ return False
405+ if not sigfile .is_file () or not modified_in (sigfile , sigfile_interval ):
406+ return True
407+ else :
408+ if log :
409+ logging .debug ("Sigfile too fresh" )
410+ return False
411+
412+
390413def async_email_timestamp (resume = False ):
391414 """If called with `resume=True`, tries to resume waiting for the mail"""
392415 logging .xdebug ("async_email_timestamp(%r)" % resume )
@@ -398,7 +421,6 @@ def async_email_timestamp(resume=False):
398421 return
399422 head = repo .head
400423 logfile = Path (path , 'pgp-timestamp.tmp' )
401- sigfile = Path (path , 'pgp-timestamp.sig' )
402424 if resume :
403425 if not logfile .is_file ():
404426 logging .stop ("Not resuming mail timestamp: No pending mail reply" )
@@ -413,13 +435,7 @@ def async_email_timestamp(resume=False):
413435 daemon = True ).start ()
414436 else : # Fresh request
415437 # No recent attempts or results for mail timestamping
416- if logfile .is_file () and modified_in (logfile , timedelta (minutes = 4 + 5 )):
417- logging .stop ("Logfile more recent than 4+5 minutes, skipping" )
418- return
419- sigfile_interval = (autoblockchainify .config .arg .commit_interval
420- * autoblockchainify .config .arg .force_after_intervals
421- - timedelta (minutes = 4 ))
422- if not sigfile .is_file () or not modified_in (sigfile , sigfile_interval ):
438+ if needs_timestamp (log = True ):
423439 new_rev = ("git commit %s\n Timestamp requested at %s\n " %
424440 (head .target .hex ,
425441 strftime ("%Y-%m-%d %H:%M:%S UTC" , gmtime ())))
0 commit comments