-
-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(streamable): Append read stream buffer to ongoing response for long items #372
fix(streamable): Append read stream buffer to ongoing response for long items #372
Conversation
4d6947a
to
7c14349
Compare
…ng items Process output is streamed into a buffer. By default this buffer fits 4k characters, which is too short for image data. With this change, if this block does not contain a stream separator, the complete block is appended to the in-progress content stored so far. Fixes swiftbar#371.
7c14349
to
f6e8988
Compare
Added conditional check for a future "SwiftBar 1.5.0" in https://github.com/peanball/music-swiftbar. The plugin falls back to not putting the artwork if SwiftBar is older than that. I will adapt to the correct version, in which this functionality is included. |
Hi @peanball, thanks for working on this ❤️
Do you happen to have a reference to documentation for this? I remember debugging this at some point, but couldn't make heads or tails of it. The change itself looks straigthforward enough 👍 |
Observation in the debugger. And 4K seemed reasonable as default set limit. There is some docs on the the behaviour of reading data, which is limited to a buffer when reading from a stream, or until end of file when reading from a file. In this case the first applies. I can find the reference later if needed. While working on the plug-in with streaming album set the image NSData kept ending up with just shy of 4K bytes, then I dug a bit deeper. I've tested it now with streaming plugins that do more and less than 4K bytes per update and both work as expected. Edit, found the bit of documentation I mention above: FileHandle.availableData:
The buffer size is not documented explicitly though. |
Regarding the |
It's fine after all. The guard acts when either there is only a single line in the next chunk read from the stream (what was there before), or there is no separator at all in the block. The no separator in the block condition applies to leading and trailing separator equally and can thus be done before evaluating that condition.
|
Can you please share the plugin you’re working on? I want to test it. |
It's the one I mention above, https://github.com/peanball/music-swiftbar And the swift script version of that, not the python version. I don't think I'll keep the python version around for much longer. |
Process output is streamed into a buffer. By default this buffer fits 4k characters, which is too short for image data.
With this change, if this block does not contain a stream separator, the complete block is appended to the in-progress content stored so far.
Fixes #371.