Socket>>sendStreamContents:checkBlock:

Dominic Letz dominic.letz at berlin.de
Mon Apr 16 23:14:25 UTC 2007


Hello Everyone,

when adding progress information to the FTPClient I found that this  
message has a Bug. It should call the "checkBlock" every 5000 thousand  
bytes - but does call it only once at the end of the file transfer.
To fix this i suggest replacing the two lines:

	[[stream atEnd and: [checkBlock value]]
		whileFalse: [

with:

	[[stream atEnd not and: [checkBlock value]]
		whileTrue: [

I'm not very familiar with changesets so this seemed me the best way of  
submitting this hint. For reference I provide the full message code here:

sendStreamContents: stream checkBlock: checkBlock
	"Send the data in the stream. Close the stream after you are done. After  
each block of data evaluate checkBlock and abort if it returns false.
	Usefull for directly sending contents of a file without reading into  
memory first."

	| chunkSize buffer |
	chunkSize _ 5000.
	buffer _ ByteArray new: chunkSize.
	stream binary.
	[[stream atEnd and: [checkBlock value]]
		whileFalse: [
			buffer _ stream next: chunkSize into: buffer.
			self sendData: buffer]]
		ensure: [stream close]


Faithfully
Dominic Letz



More information about the Squeak-dev mailing list