The Trunk: Monticello-ct.747.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Monticello-ct.747.mcz

commits-2
Marcel Taeumel uploaded a new version of Monticello to project The Trunk:
http://source.squeak.org/trunk/Monticello-ct.747.mcz

==================== Summary ====================

Name: Monticello-ct.747
Author: ct
Time: 7 May 2021, 11:45:19.014241 pm
UUID: 2cb0b275-8fb5-b149-b46d-41387d4d8f1f
Ancestors: Monticello-ct.746

Fixes a bug in MCHttpRespository(MCFileBasedRepository) >> #versionNamed: that occurred when the repository did not contain the requested version. As the comment in the superclass states, answer nil in this case instead of raising a NetworkError.

To do this, raise a more precise NotFound error in MCHttpRepository >> #webClientDo: if the version does not exist. I checked all other senders and handlers of the NetworkError; no one else depends on the old behavior.

=============== Diff against Monticello-ct.746 ===============

Item was changed:
  ----- Method: MCFileBasedRepository>>versionNamed: (in category 'versions') -----
  versionNamed: aMCVersionName
  "For FileBased repositories, aMCVersionName must have the appropriate extension!!  :-("
  | version |
  version := self cache
  at: aMCVersionName
  ifAbsent:
  [ [ self loadVersionFromFileNamed: aMCVersionName ]
+ on: FileDoesNotExistException , NotFound
- on: FileDoesNotExistException
  do: [ : err | nil ] ].
  self resizeCache: cache.
  (version notNil and: [ version isCacheable ]) ifTrue:
  [ cache
  at: aMCVersionName asMCVersionName
  put: version ].
  ^ version!

Item was changed:
  ----- Method: MCHttpRepository>>webClientDo: (in category 'private') -----
  webClientDo: aBlock
 
  | client attemptsLeft response result |
  self class useSharedWebClientInstance ifTrue: [
  "Acquire webClient by atomically storing it in the client variable and setting its value to nil."
  client := webClient.
  webClient := nil ].
 
  client
  ifNil: [ client := WebClient new ]
  ifNotNil: [
  "Attempt to avoid an error by recreating the underlying stream."
  client isConnected ifFalse: [ client close ] ].
 
  attemptsLeft := 3.
  response := nil.
  [ response isNil and: [ attemptsLeft > 0 ] ] whileTrue: [
  response := [ aBlock value: client ]
  on: NetworkError
  do: [ :error |
  attemptsLeft = 0 ifTrue: [ error pass ].
  (3 - attemptsLeft) seconds asDelay wait.
  attemptsLeft := attemptsLeft - 1.
  nil "The response" ] ].
 
  result := (response code between: 200 and: 299)
  ifFalse: [
  response content. "Make sure content is read."
  nil ]
  ifTrue: [
  (RWBinaryOrTextStream with: (
  response contentWithProgress:  [ :total :amount |
  HTTPProgress new
  total: total;
  amount: amount;
  signal ])) reset ].
 
  self class useSharedWebClientInstance
  ifTrue: [
  "Save the WebClient instance for reuse, but only if there is no client cached."
  webClient  
  ifNil: [ webClient := client ]
  ifNotNil: [ client close ] ]
  ifFalse: [ client close ].
 
+ (response code = 404 "Not Found" or: [response code = 410 "Gone"]) ifTrue: [
+ "Need to distinguish between lookup errors and connection errors. Lookup errors will be handled by some senders following the EAFP principle. See #versionNamed:."
+ (NotFound object: response url) signal ].
  result ifNil: [ NetworkError signal: 'Could not access ', location ].
  ^result!