[squeak-dev] The Trunk: UpdateStream-ct.18.mcz

commits at source.squeak.org commits at source.squeak.org
Mon Jan 3 21:33:40 UTC 2022


Christoph Thiede uploaded a new version of UpdateStream to project The Trunk:
http://source.squeak.org/trunk/UpdateStream-ct.18.mcz

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

Name: UpdateStream-ct.18
Author: ct
Time: 3 January 2022, 10:33:39.363397 pm
UUID: b48f8a5e-509e-324c-8bd6-4f75867a9e93
Ancestors: UpdateStream-dtl.17

Several improvements to multilingual support.

=============== Diff against UpdateStream-dtl.17 ===============

Item was changed:
  ----- Method: ImageReadWriter class>>formFromServerFile: (in category '*UpdateStream') -----
  formFromServerFile: fileName
  	"Answer a ColorForm stored on the file with the given name.  Meant to be called from during the getting of updates from the server.  That assures that (UpdateStreamDownloader default serverUrls) returns the right group of servers."
  
  	| urls |
  	urls := UpdateStreamDownloader default serverUrls collect:
  		[:url | url, fileName].  " fileName starts with: 'updates/'  "
  	urls do: [:aURL | | form doc |
  		(fileName findTokens: '.') last asLowercase = 'gif' ifTrue: [
  			form := HTTPSocket httpGif: aURL.
  			form = (ColorForm extent: 20 at 20 depth: 8) 
+ 				ifTrue: [self inform: ('The file {1} is ill-formed.' translated format: {aURL})].
- 				ifTrue: [self inform: 'The file ',aURL,' is ill formed.'].
  			^ form].
  		(fileName findTokens: '.') last asLowercase = 'bmp' ifTrue: [
  			doc := HTTPSocket httpGet: aURL accept: 'image/bmp'.
  			form := Form fromBMPFile: doc.
  			doc close.
+ 			form
+ 				ifNil: [
+ 					self inform: ('The file {1} is ill-formed.' translated format: {aURL}).
+ 					^ Form new]
- 			form ifNil: [self inform: 'The file ',aURL,' is ill formed.'. ^ Form new]
  				ifNotNil: [^ form]].
+ 		self inform: ('File {1} does not end with .gif or .bmp' translated format: {fileName})].
+ 	self inform: 'That file not found on any server we know' translated.!
- 		self inform: 'File ', fileName, 'does not end with .gif or .bmp'].
- 	self inform: 'That file not found on any server we know'.!

Item was changed:
  ----- Method: UpdateStreamDownloader class>>applyUpdatesFromDiskToUpdateNumber:stopIfGap: (in category 'fetching updates') -----
  applyUpdatesFromDiskToUpdateNumber: lastUpdateNumber stopIfGap: stopIfGapFlag 
  	"To use this mechanism, be sure all updates you want to have considered 
  	are in a folder named 'updates' which resides in the same directory as  
  	your image. Having done that, simply evaluate:  
  	 
  	UpdateStreamDownloader applyUpdatesFromDiskToUpdateNumber: 1234 stopIfGap: false  
  	 
  	and all numbered updates <= lastUpdateNumber not yet in the image will 
  	be loaded in numerical order."
  	| previousHighest currentUpdateNumber done fileNames aMessage updateDirectory loaded |
  	updateDirectory := self getUpdateDirectoryOrNil.
  	updateDirectory ifNil: [^ self].
  	previousHighest := SystemVersion current highestUpdate.
  	currentUpdateNumber := previousHighest.
  	done := false.
  	loaded := 0.
  	[done]
  		whileFalse: [currentUpdateNumber := currentUpdateNumber + 1.
  			currentUpdateNumber > lastUpdateNumber
  				ifTrue: [done := true]
  				ifFalse: [fileNames := updateDirectory fileNamesMatching: currentUpdateNumber printString , '*'.
  					fileNames size > 1
+ 						ifTrue: [^ self inform: ('ambiguity -- two files both start with {1}
- 						ifTrue: [^ self inform: 'ambiguity -- two files both start with ' , currentUpdateNumber printString , '
  (at this point it is probably best to remedy
+ the situation on disk, then try again.)' translated format: {currentUpdateNumber})].
- the situation on disk, then try again.)'].
  					fileNames size = 0
  						ifTrue: [Transcript cr; show: 'gap in updates from disk for update number '; print: currentUpdateNumber; show: ' found...'.
  							done := stopIfGapFlag]
  						ifFalse: [ChangeSet
  								newChangesFromStream: (updateDirectory readOnlyFileNamed: fileNames first)
  								named: fileNames first.
  							SystemVersion current registerUpdate: currentUpdateNumber.
  							loaded := loaded + 1]]].
  	aMessage := loaded = 0
+ 				ifTrue: ['No new updates found.' translated]
+ 				ifFalse: ['{1} update(s) loaded.' translated format: {loaded printString}].
+ 	self inform: ('{1}
+ Highest numbered update is now {2}.' translated format: {aMessage. currentUpdateNumber - 1}).!
- 				ifTrue: ['No new updates found.']
- 				ifFalse: [loaded printString , ' update(s) loaded.'].
- 	self inform: aMessage , '
- Highest numbered update is now ' , (currentUpdateNumber - 1) printString , '.'!

Item was changed:
  ----- Method: UpdateStreamDownloader class>>newUpdatesOn:special:throughNumber: (in category 'fetching updates') -----
  newUpdatesOn: serverList special: indexPrefix throughNumber: aNumber
  	"Return a list of fully formed URLs of update files we do not yet have.  Go to the listed servers and look at the file 'updates.list' for the names of the last N update files.  We look backwards for the first one we have, and make the list from there.  tk 9/10/97
  	No updates numbered higher than aNumber (if it is not nil) are returned " 
  
  	| existing out maxNumber |
  	maxNumber := aNumber ifNil: [99999].
  	out := OrderedCollection new.
  	existing := SystemVersion current updates.
  	serverList do: [:server | | raw doc list char |
  		doc := HTTPSocket httpGet: 'http://' , server,indexPrefix,'updates.list'.
  		
  		"test here for server being up"
  		doc class == RWBinaryOrTextStream ifTrue:
  			[raw := doc reset; contents.	"one file name per line"
  			list := self extractThisVersion: raw.
  			list reverseDo: [:fileName | | ff itsNumber |
  				ff := (fileName findTokens: '/') last.	"allow subdirectories"
  				itsNumber := ff initialIntegerOrNil. 
  				(existing includes: itsNumber)
  					ifFalse:
  						[
  						(itsNumber == nil or: [itsNumber <= maxNumber])
  							ifTrue:
  								[out addFirst: 'http://' , server, fileName]]
  					ifTrue: [^ out]].
  			((out size > 0) or: [char := doc reset; skipSeparators; next.
  				(char == $*) | (char == $#)]) ifTrue:
  					[^ out "we have our list"]].	"else got error msg instead of file"
  		"Server was down, try next one"].
+ 	self inform: 'All code update servers seem to be unavailable' translated.
- 	self inform: 'All code update servers seem to be unavailable'.
  	^ out!

Item was changed:
  ----- Method: UpdateStreamDownloader class>>objectStrmFromUpdates: (in category 'fetching updates') -----
  objectStrmFromUpdates: fileName
  	"Go to the known servers and look for this file in the updates folder.  It is an auxillery file, like .morph or a .gif.  Return a RWBinaryOrTextStream on it.    Meant to be called from during the getting of updates from the server.  That assures that (UpdateStreamDownloader serverUrls) returns the right group of servers."
  	Cursor wait showWhile:
  		[ | urls |
  		urls := UpdateStreamDownloader serverUrls collect: [:url | url, 'updates/', fileName].
  		urls do: [:aUrl | | doc |
  			doc := HTTPSocket httpGet: aUrl accept: 'application/octet-stream'.
  			"test here for server being up"
  			doc class == RWBinaryOrTextStream ifTrue: [^ doc reset]]].
  
+ 	self inform: 'All update servers are unavailable, or bad file name' translated.
- 	self inform: 'All update servers are unavailable, or bad file name'.
  	^ nil!

Item was changed:
  ----- Method: UpdateStreamDownloader class>>position:atVersion: (in category 'fetching updates') -----
  position: updateStrm atVersion: version
  	"Set the stream to the end of the last line of updates names for this version.  Usually the end of the file.  We will add a new update name.   Return the contents of the rest of the file."
  
  	| char foundIt where data |
  	updateStrm reset; ascii.
  	foundIt := false.
  	[char := updateStrm next.
  	 updateStrm atEnd] whileFalse: [
  		(char == Character cr or: [char == Character lf]) ifTrue: [
  			updateStrm peek == $# ifTrue: [
  				foundIt ifTrue: ["Next section"
  					where := updateStrm position.
  					data := updateStrm upTo: (255 asCharacter).
  					updateStrm position: where.
  					^ data].	"won't be found -- copy all the way to the end"
  				updateStrm next.
  				(updateStrm nextMatchAll: version) ifTrue: [
  					(updateStrm atEnd or: [(updateStrm peek = Character cr) | 
  						(updateStrm peek = Character lf)]) ifTrue: [
  							foundIt := true
  					]]]]].
  	foundIt ifTrue: [
  		updateStrm setToEnd.
  		^ ''].
+ 	self error: 'The current version does not have a section in the Updates file' translated.!
- 	self error: 'The current version does not have a section in the Updates file'.
- !



More information about the Squeak-dev mailing list