From 3ebaa05ea0f116a861b4fb137be34d56ab022f2d Mon Sep 17 00:00:00 2001 From: ruidajo Date: Mon, 4 Apr 2022 16:41:12 -0500 Subject: [PATCH 1/2] Refactoring nitter user exporter. --- .../{exportWithTemplate.On..st => exportWithTemplate.into..st} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Socialmetrica.package/NitterUser.class/instance/{exportWithTemplate.On..st => exportWithTemplate.into..st} (89%) 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. From cdac1e3af77b8c2a904b4869cc4bc2f18a4fca25 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Mon, 4 Apr 2022 19:06:21 -0500 Subject: [PATCH 2/2] Improved store contents for NitterUser. --- .../instance/storeContents.st | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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