added remove all item from queue
This commit is contained in:
@@ -232,6 +232,40 @@ async def clear_failed(
|
||||
)
|
||||
|
||||
|
||||
@router.delete("/pending", status_code=status.HTTP_200_OK)
|
||||
async def clear_pending(
|
||||
_: dict = Depends(require_auth),
|
||||
download_service: DownloadService = Depends(get_download_service),
|
||||
):
|
||||
"""Clear all pending downloads from the queue.
|
||||
|
||||
Removes all pending download items from the queue. This is useful for
|
||||
clearing the entire queue at once instead of removing items one by one.
|
||||
|
||||
Requires authentication.
|
||||
|
||||
Returns:
|
||||
dict: Status message with count of cleared items
|
||||
|
||||
Raises:
|
||||
HTTPException: 401 if not authenticated, 500 on service error
|
||||
"""
|
||||
try:
|
||||
cleared_count = await download_service.clear_pending()
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"message": f"Removed {cleared_count} pending item(s)",
|
||||
"count": cleared_count,
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"Failed to clear pending items: {str(e)}",
|
||||
)
|
||||
|
||||
|
||||
@router.delete("/{item_id}", status_code=status.HTTP_204_NO_CONTENT)
|
||||
async def remove_from_queue(
|
||||
item_id: str = Path(..., description="Download item ID to remove"),
|
||||
|
||||
Reference in New Issue
Block a user