Merge 610c8e4ca1
This commit is contained in:
commit
2e6e480668
@ -1,4 +1,4 @@
|
|||||||
accessing
|
accessing
|
||||||
downloadProfileImage
|
downloadProfileImage
|
||||||
|
|
||||||
^ self exportProfileImageOn: self folder / self userName, 'jpg'
|
^ self exportProfileImageOn: self folder / 'profile-image', 'jpg'
|
@ -1,11 +1,48 @@
|
|||||||
accessing
|
accessing
|
||||||
exportProfileImageOn: fileReference
|
exportProfileImageOn: fileReference
|
||||||
|
|
||||||
| file |
|
| file tempFile tempFileHash fileHash |
|
||||||
file := fileReference asFileReference.
|
file := fileReference asFileReference.
|
||||||
file ensureDelete.
|
file exists
|
||||||
file exists ifFalse: [ file ensureCreateFile ].
|
ifFalse: [ file ensureCreateFile.
|
||||||
file binaryWriteStreamDo: [ :stream |
|
file binaryWriteStreamDo: [ :stream |
|
||||||
stream nextPutAll: profileImageUrl retrieveContents ].
|
stream nextPutAll: profileImageUrl retrieveContents ].
|
||||||
super class inform: 'Exported as: ', String cr, file fullName.
|
super class inform: 'Exported as: ', String cr, file fullName.
|
||||||
^ file
|
^ file]
|
||||||
|
|
||||||
|
ifTrue: [
|
||||||
|
tempFile := FileLocator temp / fileReference basename.
|
||||||
|
tempFile ensureCreateFile.
|
||||||
|
tempFile binaryWriteStreamDo: [ :stream |
|
||||||
|
stream nextPutAll: profileImageUrl 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 /
|
||||||
|
(file basenameWithoutExtension , '-',
|
||||||
|
('-' join:
|
||||||
|
((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg').
|
||||||
|
file ensureDelete.
|
||||||
|
^ { 'Profile image changed' ->
|
||||||
|
(tempFile moveTo: file)} asDictionary ]].
|
||||||
|
^ { 'Same Profile Image' -> file } asDictionary
|
Loading…
Reference in New Issue
Block a user