I've made some improvements to the HTTP downloading code used in BottomFeeder. The stock code downloads everything into memory, with no real option to save to a file. I added some support code to do that a long while back for the upgrade tools, but they simply dropped the downloaded bytes to a file as soon as they were all in - which still filled a large memory buffer when it happened.
Now, that's been improved. I made some modifications to the HttpClient subclass I use in the upgrade tools, and gave it the ability to download straight to a file. This makes the EnclosureHandler practical - previously, using it could run past your memory settings, and cause problems (or simply cause excessive memory use). Now, that's no longer an issue. Next, I need to look at some code Blaine sent me. It was written for Dolphin, but the porting should mainly be in the file/stream area. It provides direct access to the iPod, which would be very nice.
The changes necessary weren't terribly complex - when the HttpClient starts grabbing data, it sets up a stream to download to in class HttpBuildHandler:
openBodyStream: aMessageBody aMessageBody isSimple ifTrue: [aMessageBody setByteSource: (ReadWriteStream on: (ByteArray new: 1024)) ]
All I did is have that code open a stream on a file (yes, it's simplistic - I only use this subclass to download files). The only hard part comes into cleanup; I trigger events so that the object that kicks off the download can move the file that's downloaded (to a temp file name) to the place and name it belongs. It works pretty well, and I'm happily using it. To get the update, you need to:
- Be on version 4.2
- Change your update path to end in /dev
- Grab all available updates
If you try that and have problems, let me know.
Update: I posted a new build under the dev downloads. So you can just grab that.
Technorati Tags: smalltalk