Report generated on Sep-15 12:00 am
Pier last restarted: Sep-04 12:52 pm
A-OK - Image file is newer (Sep-14 6:25 pm)
(PRScheduledTaskExamples newForKernelNamed: 'Pier') reportOfFile: 'STARTED_PHARO.txt' onPageAt: '/Blog/Social Tasks/Democracy Action/Check Image Save/Report' modifyUsing: [ :restartString || imageFile transactionFile prefix lastRestart lastLine todo | prefix := ''. lastRestart := DateAndTime epoch. todo := PRPathLookup start: (PRKernel instanceNamed: 'Pier') root path: '/Blog/Social Tasks/Democracy Action'. (restartString isEmpty not and: [ (lastLine := restartString lines last) size > 74 ]) ifTrue: [ lastRestart := [ | date time | date := ((lastLine copyFrom: 51 to: 57), (lastLine copyFrom: 71 to: 74)) asDate. time := (lastLine copyFrom: 58 to: 65) asTime. DateAndTime date: date time: time ] on: Error do: [ DateAndTime epoch ]. prefix := 'Pier last restarted: ', (todo displayDateWithTimeZoneDifference: lastRestart), Character cr asString, Character cr asString ]. (imageFile := FileLocator workingDirectory / Smalltalk imageFile basename) exists ifFalse: [ 'Image file does not exist!' ] ifTrue: [ (transactionFile := FileLocator workingDirectory / 'transactions.txt') exists ifFalse: [ 'Transaction file does not exist!' ] ifTrue: [ ((FileSystem disk modificationTimeOf: transactionFile) between: (FileSystem disk modificationTimeOf: imageFile) and: lastRestart) ifTrue: [ prefix, 'NOT OK - Pier was restarted after changes but before image save' ] ifFalse: [ (FileSystem disk modificationTimeOf: imageFile) > (FileSystem disk modificationTimeOf: transactionFile) ifTrue: [ prefix, 'A-OK - Image file is newer (' , (todo displayDateWithTimeZoneDifference: (FileSystem disk modificationTimeOf: imageFile)) , ')' ] ifFalse: [ (PRKernel instanceNamed: 'Pier') 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!' ] ] ] ] ] ].
Explanation:
Other discoveries:
Smalltalk imageFile
is the memory file, it is constantly being updated - use the file name instead - Check with: FileSystem disk modificationTimeOf: Smalltalk imageFile