From bd279b1fd3a8933ad4c10be13f822ce4492b8423 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Mon, 25 Apr 2022 06:26:54 -0500 Subject: [PATCH] Code Review: Formatting and ward clause. Method should be made more modular. --- .../instance/exportProfileImageOn..st | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/Socialmetrica.package/NitterUser.class/instance/exportProfileImageOn..st b/Socialmetrica.package/NitterUser.class/instance/exportProfileImageOn..st index 165a851..ddb6426 100644 --- a/Socialmetrica.package/NitterUser.class/instance/exportProfileImageOn..st +++ b/Socialmetrica.package/NitterUser.class/instance/exportProfileImageOn..st @@ -3,39 +3,38 @@ exportProfileImageOn: fileReference | file tempFile tempFileHash fileHash | file := fileReference asFileReference. - file exists - ifFalse: [ file ensureCreateFile. + file exists ifFalse: [ + file ensureCreateFile. file binaryWriteStreamDo: [ :stream | - stream nextPutAll: profileImageUrl asUrl retrieveContents ]. - super class inform: 'Exported as: ', String cr, file fullName. - ^ file] + stream nextPutAll: profileImageUrl asUrl retrieveContents ]. + super class inform: 'Exported as: ', String cr, file fullName. + ^ file + ]. + tempFile := FileLocator temp / fileReference basename. + tempFile ensureCreateFile. + tempFile binaryWriteStreamDo: [ :stream | + stream nextPutAll: profileImageUrl asUrl retrieveContents. + super class inform: 'Exported as: ', String cr, tempFile fullName. + ]. + + OSSUnixSubprocess new + command: 'openssl'; + arguments: { 'dgst' . '-sha256' . file fullName}; + workingDirectory: (self folder)fullName; + redirectStdout; + redirectStderr; + runAndWaitOnExitDo: [ :process :outString | + fileHash := (outString splitOn: ' ' ) second trimmed]. + + OSSUnixSubprocess new + command: 'openssl'; + arguments: { 'dgst' . '-sha256' . tempFile fullName}; + workingDirectory: (self folder)fullName; + redirectStdout; + redirectStderr; + runAndWaitOnExitDo: [ :process :outString | + tempFileHash := (outString splitOn: ' ' ) second trimmed]. - ifTrue: [ - tempFile := FileLocator temp / fileReference basename. - tempFile ensureCreateFile. - tempFile binaryWriteStreamDo: [ :stream | - stream nextPutAll: profileImageUrl asUrl retrieveContents. - super class - inform: 'Exported as: ', String cr, tempFile fullName. ]. - - OSSUnixSubprocess new - command: 'openssl'; - arguments: { 'dgst' . '-sha256' . file fullName}; - workingDirectory: (self folder)fullName; - redirectStdout; - redirectStderr; - runAndWaitOnExitDo: [ :process :outString | - fileHash := (outString splitOn: ' ' ) second trimmed]. - - OSSUnixSubprocess new - command: 'openssl'; - arguments: { 'dgst' . '-sha256' . tempFile fullName}; - workingDirectory: (self folder)fullName; - redirectStdout; - redirectStderr; - runAndWaitOnExitDo: [ :process :outString | - tempFileHash := (outString splitOn: ' ' ) second trimmed]. - fileHash = tempFileHash ifFalse: [ file copyTo: self folder / @@ -44,5 +43,5 @@ exportProfileImageOn: fileReference ((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg'). file ensureDelete. ^ { 'Profile image changed' -> - (tempFile moveTo: file)} asDictionary ]]. + (tempFile moveTo: file)} asDictionary ]. ^ { 'Same Profile Image' -> file } asDictionary \ No newline at end of file