Re: random maddening bug - "corrupted" file upload contents
Bob Arning <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.seaside |
|---|---|
| Message-ID | <[email protected]> |
I've been able to boil it down to one method. This fails sometimes and succeeds sometimes. Whichever it does, it tends to keep doing that for a while. Quitting and restarting may get it to change. test4 " self test4 " | species bufferSize buffer totalRead outputStream answer inputStream ba byte1 | false ifTrue: [ ba := (FileStream readOnlyFileNamed: '/Users/bob/z99.zip') binary; contentsOfEntireFile. ] ifFalse: [ ba := ByteArray new: 18202085. ba atAllPut: 99. 1 to: 20 do: [ :i | ba at: i put: (#[80 75 3 4 10 7 7 7 7 7 125 83 67 73 7 7 7 7 7 7] at: i) ]. ]. inputStream := ba readStream. bufferSize := 16384. species := ByteArray. buffer := species new: bufferSize. totalRead := 0. outputStream := nil. [ inputStream atEnd ] whileFalse: [ | readCount | readCount := inputStream readInto: buffer startingAt: 1 count: bufferSize. totalRead = 0 ifTrue: [ byte1 := buffer first. ]. totalRead := totalRead + readCount. outputStream ifNil: [ inputStream atEnd ifTrue: [ ^ buffer copyFrom: 1 to: readCount ] ifFalse: [ outputStream := (species new: bufferSize) writeStream ] ]. outputStream next: readCount putAll: buffer startingAt: 1. byte1 = outputStream firstByte ifFalse: [ self halt ]. ]. answer := outputStream ifNil: [ species new ] ifNotNil: [ outputStream contents ]. byte1 = answer first ifFalse: [ self halt ]. ^answer On 1/10/18 4:42 AM, Cyrille Delaunay wrote: > > Has anyone been able to reproduce my little scenario ? > As a reminder, suspicion is that something "wrong" has been introduced > with Pharo6 _______________________________________________ seaside mailing list [email protected] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside