Improved store contents for NitterUser.
This commit is contained in:
parent
3ebaa05ea0
commit
cdac1e3af7
@ -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.
|
Loading…
Reference in New Issue
Block a user