Code Review: Formatting and ward clause. Method should be made more modular.
This commit is contained in:
parent
bbfae14949
commit
bd279b1fd3
@ -3,39 +3,38 @@ exportProfileImageOn: fileReference
|
|||||||
|
|
||||||
| file tempFile tempFileHash fileHash |
|
| file tempFile tempFileHash fileHash |
|
||||||
file := fileReference asFileReference.
|
file := fileReference asFileReference.
|
||||||
file exists
|
file exists ifFalse: [
|
||||||
ifFalse: [ file ensureCreateFile.
|
file ensureCreateFile.
|
||||||
file binaryWriteStreamDo: [ :stream |
|
file binaryWriteStreamDo: [ :stream |
|
||||||
stream nextPutAll: profileImageUrl asUrl retrieveContents ].
|
stream nextPutAll: profileImageUrl asUrl retrieveContents ].
|
||||||
super class inform: 'Exported as: ', String cr, file fullName.
|
super class inform: 'Exported as: ', String cr, file fullName.
|
||||||
^ file]
|
^ 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
|
fileHash = tempFileHash
|
||||||
ifFalse: [
|
ifFalse: [
|
||||||
file copyTo: self folder /
|
file copyTo: self folder /
|
||||||
@ -44,5 +43,5 @@ exportProfileImageOn: fileReference
|
|||||||
((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg').
|
((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg').
|
||||||
file ensureDelete.
|
file ensureDelete.
|
||||||
^ { 'Profile image changed' ->
|
^ { 'Profile image changed' ->
|
||||||
(tempFile moveTo: file)} asDictionary ]].
|
(tempFile moveTo: file)} asDictionary ].
|
||||||
^ { 'Same Profile Image' -> file } asDictionary
|
^ { 'Same Profile Image' -> file } asDictionary
|
Loading…
Reference in New Issue
Block a user