Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Fix addnext failing on an empty queue #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jwaataja
Copy link

Previously, addnext would try to unconditionally add at index one into a
queue. This panicked if the queue was empty. Added two protections, one
that checks the index in the InsertTrack function, the other in the
addnext command itself to insert at zero if the queue is empty.

Before submitting this pull request, please acknowledge that you have done the following:

  • I have tested my changes to make sure that they work
  • I have at least attempted to write relevant unit tests to verify that my changes work
  • I have read through the contribution guidelines
  • I have written any necessary documentation (for example, adding information about a feature to the README)

What type of pull request is this?

  • Bug fix
  • Typo fix
  • New feature implementation
  • New service implementation
  • Other

Description of your pull request:

Fixes that addnext fails on an empty queue. This is because it unconditionally tries to insert at index one, which is out of range for an empty queue. Added a check to return an error if an invalid index is passed. To fix the bug itself, I added an extra case to addnext that inserts at zero instead.

I couldn't think of a way to write unit tests for this as it would require passing an actual url to addnext. Running it seems to work now, though.

Previously, addnext would try to unconditionally add at index one into a
queue. This panicked if the queue was empty. Added two protections, one
that checks the index in the InsertTrack function, the other in the
addnext command itself to insert at zero if the queue is empty.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant