Check Image Save

Report generated on May-08 4:00 pm

Pier last restarted: Sat Apr 13 16:32:01 UTC 2024

Could be OK - There are unsaved edits, but transactions is not older than persistency duration


(PRScheduledTaskExamples newForKernelNamed: 'Pier') reportOfFile: 'STARTED_PHARO.txt' onPageAt: '/Blog/Social Tasks/Democracy Action/Check Image Save/Report' modifyUsing: [ :str || imageFile transactionFile prefix | prefix := ''. (str isEmpty not and: [ str lines last size > 75 ]) ifTrue: [ prefix := 'Pier last restarted: ', (str lines last copyFrom: 47 to: 74), String crlfcrlf ]. (imageFile := Smalltalk imageFile) exists ifFalse: [ 'Image file does not exist!' ] ifTrue: [ (transactionFile := FileLocator workingDirectory / 'transactions.txt') exists ifFalse: [ 'Transaction file does not exist!' ] ifTrue: [ PRKernel instances size = 1 ifFalse: [ 'Code is not prepared for more than 1 kernel' ] ifTrue: [ (FileSystem disk modificationTimeOf: imageFile) > (FileSystem disk modificationTimeOf: transactionFile) ifTrue: [ prefix, 'A-OK - Image file is newer (' , (FileSystem disk modificationTimeOf: imageFile) asString , ')' ] ifFalse: [ (PRKernel instances anyOne persistency duration > ((FileSystem disk modificationTimeOf: transactionFile) - (FileSystem disk modificationTimeOf: imageFile))) ifTrue: [ prefix, 'Maybe OK - There are edits that have not yet been saved.' ] ifFalse: [ PRKernel instances anyOne persistency duration > (DateAndTime now - (FileSystem disk modificationTimeOf: transactionFile)) ifTrue: [ prefix, 'Could be OK - There are unsaved edits, but transactions is not older than persistency duration' ] ifFalse: [ prefix, 'NOT OK - There are edits that may be lost!' ] ] ] ] ] ] ].

Explaining:

  • Add a prefix for the last time check_pier.sh restarted pier
  • Sanity checks:
    • Image file must exist
    • transactions.txt should exist if anything has been edited
    • There must be only 1 kernel
  • If the image file is newer than transaction.txt, there is no concern
  • otherwise:
    • Time difference between transactions.txt and the image is less than the persistency duration, then edits should be saved soon
    • Otherwise
      • If the time between now and the last edit is less than the persistency duration, then the edits should be saved soon
      • When there are edits older than the persistency and the image has not been saved since then then edits have been lost!