Improved store contents for NitterUser.

This commit is contained in:
ruidajo 2022-04-04 19:06:21 -05:00
parent 3ebaa05ea0
commit cdac1e3af7

View File

@ -1,6 +1,23 @@
accessing accessing
storeContents storeContents
| objectString | | objectString directory tempFile oldFile |
objectString := STON toStringPretty: self. objectString := STON toStringPretty: self.
^ MarkupFile exportAsFileOn: self folder/ self userName, 'ston' containing: objectString. directory := (FileLocator userData / 'Socialmetrica' / self userName) ensureCreateDirectory.
oldFile := directory / self userName, 'ston'.
oldFile exists ifFalse: [
^ MarkupFile exportAsFileOn: oldFile containing: objectString ].
tempFile := MarkupFile
exportAsFileOn: FileLocator temp / self userName, 'ston'
containing: objectString.
(tempFile contents hash hex = oldFile contents hash hex) ifFalse: [
oldFile copyTo: directory /
(oldFile basenameWithoutExtension , '-',
('-' join:((oldFile creationTime asLocalStringYMDHM) splitOn: ' ')),
'.ston').
oldFile ensureDelete.
^ { 'Profile changed' -> (tempFile moveTo: oldFile)} asDictionary ].
^ { 'Same Profile' -> oldFile } asDictionary.