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

View File

@ -13,6 +13,17 @@ GrafoscopioUtils class >> checksumFor: aFileReference [
^ (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' }
GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into: location [
| fileName |
@ -33,6 +44,18 @@ GrafoscopioUtils class >> downloadingFrom: downloadUrl withMessage: aString into
] 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' }
GrafoscopioUtils class >> getContentsFrom: url withMessage: aString [
| client |