Smallwiki Storage Work-arounds

Since the Smallwiki is being stored in the image, when the machine crashes, the changes made since the last save are lost. For Pier, using image persistency takes care of these problems.

As reference, for Smallwiki 1, to keep these around, the page edit class was changed to write each page update to a file. This involved the following changes:

  • Added ProjectLogFile to SWPageEdit, with the following accessor: =SWPageEdit class>>protectLogFile

          ProtectLogFile isNil
                  ifTrue: [ProtectLogFile := Semaphore forMutualExclusion].
          ^ ProtectLogFile

  • Add a helper function for changing funny characters (ie Windows-1252): =SWPageEdit>>translateMSCharacters

          | table |
          table := String withAll: Character allCharacters.
          table at: 214 put: $';
                   at: 213 put: $';
                   at: 212 put: $";
                   at: 211 put: $";
                   at: 209 put: $-.
          self
                  wiki: (self wiki translateWith: table)

  • Finally, modify the private save: =SWPageEdit>>privateSave

          self translateMSCharacters.
          self class protectLogFile
                  critical: [| dir file |
                          file := nil.
                          [((dir := FileDirectory default) fileExists: 'pageChanges.txt')
                                  ifTrue: [file := dir oldFileNamed: 'pageChanges.txt']
                                  ifFalse: [file := dir newFileNamed: 'pageChanges.txt'].
                          file setToEnd; cr; nextPutAll: structure url; space; nextPutAll: self request user username; space; nextPutAll: TimeStamp current printString; cr; nextPutAll: wiki; cr]
                                  ensure: [file isNil
                                                  ifFalse: [file close]]].
          structure document: document

When the wiki would need to be restarted, the file pageChanges.txt could be used to check the recent changes. For pier, if the persistency PRImagePersistency is chosen, then the file transactions.txt provides similar information.