Improved support for downloading files and creation of local subdirectories for them.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-12-07 11:21:36 +00:00
parent e26ce5cb89
commit a7e72b5d9d
2 changed files with 27 additions and 7 deletions

View File

@ -71,17 +71,14 @@ GrafoscopioDocumentation >> documents: anObject [
{ #category : #updating } { #category : #updating }
GrafoscopioDocumentation >> download: fileNameWithRelativePath [ GrafoscopioDocumentation >> download: fileNameWithRelativePath [
| fileName relativePathFolders newPath parentFolder | | fileName parentFolder |
fileName := (fileNameWithRelativePath splitOn: $/) last. fileName := (fileNameWithRelativePath splitOn: $/) last.
relativePathFolders := (fileNameWithRelativePath splitOn: $/) allButLast. parentFolder := GrafoscopioUtils
newPath := self localPlace path. ensureCreateDirectory: fileNameWithRelativePath into: self localPlace.
relativePathFolders do: [ :folder | newPath := newPath / folder ].
parentFolder := newPath asFileReference.
parentFolder exists ifFalse: [ parentFolder ensureCreateDirectory ].
GrafoscopioUtils GrafoscopioUtils
downloadingFrom: self repository remote asString, '/doc/tip/', fileNameWithRelativePath downloadingFrom: self repository remote asString, '/doc/tip/', fileNameWithRelativePath
withMessage: 'Downloading ', fileName withMessage: 'Downloading ', fileName
into: parentFolder into: parentFolder
] ]
{ #category : #updating } { #category : #updating }

View File

@ -13,6 +13,17 @@ GrafoscopioUtils class >> checksumFor: aFileReference [
^ (SHA1 new hashMessage: aFileReference binaryReadStream contents) hex. ^ (SHA1 new hashMessage: aFileReference binaryReadStream contents) hex.
] ]
{ #category : #updating }
GrafoscopioUtils class >> download: fileNameWithRelativePath from: urlString into: aFolder [
| fileName parentFolder |
fileName := (fileNameWithRelativePath splitOn: $/) last.
parentFolder := self ensureCreateDirectory: fileNameWithRelativePath into: aFolder.
self
downloadingFrom: urlString, fileNameWithRelativePath
withMessage: 'Downloading ', fileName
into: parentFolder
]
{ #category : #'graphical interface' } { #category : #'graphical interface' }
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [ GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
| fileName | | fileName |
@ -33,6 +44,18 @@ GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into
] asJob run. ] asJob run.
] ]
{ #category : #utilities }
GrafoscopioUtils class >> ensureCreateDirectory: fileNameWithRelativePath into: aFolder [
| relativePathFolders parentFolder newPath |
relativePathFolders := (fileNameWithRelativePath splitOn: $/) allButLast.
newPath := aFolder path.
relativePathFolders do: [ :folder | newPath := newPath / folder ].
parentFolder := newPath asFileReference.
parentFolder ensureCreateDirectory.
^ parentFolder
]
{ #category : #'graphical interface' } { #category : #'graphical interface' }
GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [ GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [
| client | | client |