mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 00:25:49 +03:00
[PR #119] [MERGED] Check availability before conditionals #167
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#167
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kokarare1212/librespot-python/pull/119
Author: @yeralin
Created: 3/10/2022
Status: ✅ Merged
Merged: 3/10/2022
Merged by: @kokarare1212
Base:
rewrite← Head:fix-read-stream📝 Commits (1)
90c35b4Check availability before conditionals📊 Changes
1 file changed (+1 additions, -2 deletions)
View changed files
📝
librespot/audio/__init__.py(+1 -2)📄 Description
While using
librespot-pythonlibrary I encountered a bug while reading from a stream.When we are loading the last bytes of the current chunk byte-array
self.buffer()[chunk], on the next iteration we will try to accessself.buffer()[chunk+1]which is not loaded yet i.e.len(self.buffer()[chunk+1]) == 0.This causes
if chunk_off + __size > len(self.buffer()[chunk])statement to always resolve toTruewhich then writes an entireself.buffer()[chunk+1]into the buffer as opposed to writing only requested part of it of__size.Therefore, I moved
self.check_availability(chunk, True, False)to the top, so thatlen(self.buffer()[chunk+1])gets loaded before these conditional checks get executed.Then,
len(self.buffer()[chunk+1]) > 0and the conditional logic works as expected.Let me know if you need any further clarifications.
I don't foresee any risks with this PR, since we call
self.check_availability(chunk, True, False)after these checks in any case.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.