Socket>>sendStreamContents:checkBlock:

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

Socket>>sendStreamContents:checkBlock:

Dominic Letz
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

Reply | Threaded
Open this post in threaded view
|

Re: Socket>>sendStreamContents:checkBlock:

Göran Krampe
Hi!

"Dominic Letz" <[hidden email]> wrote:

> 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.

I can at least say that the bug looks real (from staring at the code)
and your fix looks sound (from staring at it). :)

regards, Göran

Reply | Threaded
Open this post in threaded view
|

Re: Socket>>sendStreamContents:checkBlock:

Dominic Letz
Ok, so what to do now about this?

Am 17.04.2007, 08:51 Uhr, schrieb <[hidden email]>:

> Hi!
>
> "Dominic Letz" <[hidden email]> wrote:
>> 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.
>
> I can at least say that the bug looks real (from staring at the code)
> and your fix looks sound (from staring at it). :)
>
> regards, Göran
>



Reply | Threaded
Open this post in threaded view
|

Re: Socket>>sendStreamContents:checkBlock:

Göran Krampe
Hi!

> Ok, so what to do now about this?

Produce a changeset and upload it at mantis. I can't do it right now but
you can surely get help on IRC from someone to do it. Or check the wiki,
there must be instructions there somewhere.

regards, Göran


Reply | Threaded
Open this post in threaded view
|

Re: Socket>>sendStreamContents:checkBlock:

Dominic Letz
ACK - http://bugs.squeak.org/view.php?id=6430

Am 18.04.2007, 10:26 Uhr, schrieb Göran Krampe <[hidden email]>:

> Hi!
>
>> Ok, so what to do now about this?
>
> Produce a changeset and upload it at mantis. I can't do it right now but
> you can surely get help on IRC from someone to do it. Or check the wiki,
> there must be instructions there somewhere.
>
> regards, Göran
>
>