diff --git a/Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.On..st b/Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.into..st similarity index 89% rename from Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.On..st rename to Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.into..st index 6f00dac..0e560ef 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.On..st +++ b/Socialmetrica.package/NitterUser.class/instance/exportWithTemplate.into..st @@ -1,5 +1,5 @@ accessing -exportWithTemplate: mustacheFile On: folder +exportWithTemplate: mustacheFile into: folder | tempDictionary modified | tempDictionary := self asDictionary copy. diff --git a/Socialmetrica.package/NitterUser.class/instance/storeContents.st b/Socialmetrica.package/NitterUser.class/instance/storeContents.st index bbbf6da..3aea2a2 100644 --- a/Socialmetrica.package/NitterUser.class/instance/storeContents.st +++ b/Socialmetrica.package/NitterUser.class/instance/storeContents.st @@ -1,6 +1,23 @@ accessing storeContents - | objectString | + | objectString directory tempFile oldFile | objectString := STON toStringPretty: self. - ^ MarkupFile exportAsFileOn: self folder/ self userName, 'ston' containing: objectString. \ No newline at end of file + 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. \ No newline at end of file