This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-04-05 15:31:21 -05:00
commit 3ef2289bbe
2 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,5 @@
accessing
exportWithTemplate: mustacheFile On: folder
exportWithTemplate: mustacheFile into: folder
| tempDictionary modified |
tempDictionary := self asDictionary copy.

View File

@ -1,6 +1,23 @@
accessing
storeContents
| objectString |
| objectString directory tempFile oldFile |
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.