Skip to content
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

Deleting items from the queue always deletes them from disk, regardless of how remove_from_client is set #172

Open
2 tasks done
BrilliantBard opened this issue May 7, 2024 · 0 comments
Labels
type/bug Something isn't working

Comments

@BrilliantBard
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behaviour

The del_queue method which deletes an item from the activity queue has a parameter called remove_from_client which should set the removeFromClient parameter in the DELETE request made to the *arr API. This parameter defaults to true in the API docs, but will only be sent if the value passed into the method is truthy, meaning it can never be set explicitly to false.

Steps To Reproduce

from pyarr import SonarrAPI
sonarr = SonarrAPI(host_url, api_key)
sonarr.del_queue(1, remove_from_client=False)

Expected behaviour

I would expect a DELETE API call to be made to Sonarr with the removeFromClient parameter set to false.

Instead, the following API call is made without the parameter being included:

DELETE /api/v3/queue/1 HTTP/1.1
Host: localhost:8989
User-Agent: python-requests/2.31.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
X-Api-Key: [REDACTED]
Content-Length: 0

The reason for this is faulty logic on line 500 in base.py which means the removeFromClient parameter can only be set if it is truthy. This is the wrong way around since API defaults this value to true.

pyarr/pyarr/base.py

Lines 483 to 505 in 09e489b

def del_queue(
self,
id_: int,
remove_from_client: Optional[bool] = None,
blocklist: Optional[bool] = None,
) -> Union[Response, JsonObject, dict[Any, Any]]:
"""Remove an item from the queue and blocklist it
Args:
id_ (int): ID of the item to be removed
remove_from_client (Optional[bool], optional): Remove the item from the client. Defaults to None.
blocklist (Optional[bool], optional): Add the item to the blocklist. Defaults to None.
Returns:
Response: HTTP Response
"""
params = {}
if remove_from_client:
params["removeFromClient"] = remove_from_client
if blocklist:
params["blocklist"] = blocklist
return self._delete(f"queue/{id_}", self.ver_uri, params=params)

Pyarr Version

v5.2.0

Python Version

3.10.12

Example Code

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@BrilliantBard BrilliantBard added the type/bug Something isn't working label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant