Code review: improved modularity. A second pass on #downloadWithRenaming: still pending.
This commit is contained in:
parent
bd279b1fd3
commit
3ff8dfc86a
@ -0,0 +1,40 @@
|
|||||||
|
as yet unclassified
|
||||||
|
downloadWithRenaming: fileReference
|
||||||
|
|
||||||
|
| file tempFile fileHash tempFileHash |
|
||||||
|
file := fileReference asFileReference .
|
||||||
|
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 /
|
||||||
|
(file basenameWithoutExtension , '-',
|
||||||
|
('-' join:
|
||||||
|
((file creationTime asLocalStringYMDHM) splitOn: ' ')), '.jpg').
|
||||||
|
file ensureDelete.
|
||||||
|
^ { 'Profile image changed' ->
|
||||||
|
(tempFile moveTo: file)} asDictionary ].
|
||||||
|
^ { 'Same Profile Image' -> file } asDictionary
|
@ -1,47 +1,13 @@
|
|||||||
accessing
|
accessing
|
||||||
exportProfileImageOn: fileReference
|
exportProfileImageOn: fileReference
|
||||||
|
|
||||||
| file tempFile tempFileHash fileHash |
|
| file |
|
||||||
file := fileReference asFileReference.
|
file := fileReference asFileReference.
|
||||||
file exists ifFalse: [
|
file exists 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.
|
self class inform: 'Exported as: ', String cr, file fullName.
|
||||||
^ file
|
^ file
|
||||||
].
|
].
|
||||||
tempFile := FileLocator temp / fileReference basename.
|
self downloadWithRenaming: fileReference
|
||||||
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 /
|
|
||||||
(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