mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fixed bug with with type in returned JSON introduced in previous commit
Also removed some redundant return statements
This commit is contained in:
parent
25aea216c5
commit
c56a23d21c
2 changed files with 11 additions and 18 deletions
|
@ -66,16 +66,6 @@ async def rpc(request: Request,
|
|||
returned_data["resultcount"] = 0
|
||||
returned_data["type"] = type
|
||||
|
||||
# Ensure type is valid.
|
||||
if type is None:
|
||||
returned_data["type"] = "error"
|
||||
returned_data["error"] = "No request type/data specified."
|
||||
return returned_data
|
||||
elif type not in ("info", "multiinfo"):
|
||||
returned_data["type"] = "error"
|
||||
returned_data["error"] = "Incorrect request type specified."
|
||||
return returned_data
|
||||
|
||||
# Take arguments from either 'args' or 'args[]' and put them into 'argument_list'.
|
||||
argument_list = []
|
||||
|
||||
|
|
|
@ -165,11 +165,6 @@ def RPC(**function_args):
|
|||
# Get Snapshot URI
|
||||
snapshot_uri = config.get("options", "snapshot_uri")
|
||||
|
||||
# Remove duplicate arguments if type is 'info' or 'multiinfo' so we don't
|
||||
# fetch results for a package multiple times.
|
||||
if type in ("info", "multiinfo"):
|
||||
args = set(args)
|
||||
|
||||
# Set request type to run.
|
||||
type_actions = {
|
||||
"info": run_info,
|
||||
|
@ -181,18 +176,26 @@ def RPC(**function_args):
|
|||
if type in type_actions:
|
||||
run_request = type_actions.get(type)
|
||||
|
||||
# If type is 'info', overwrite type to 'multiinfo' to match the
|
||||
# behavior of the PHP implementation.
|
||||
if type == "info":
|
||||
returned_data["type"] = "multiinfo"
|
||||
|
||||
# Remove duplicate arguments if type is 'multiinfo' so we don't
|
||||
# fetch results for a package multiple times.
|
||||
if returned_data["type"] == "multiinfo":
|
||||
args = set(args)
|
||||
|
||||
for i in args:
|
||||
returned_data = run_request(returned_data, i, snapshot_uri)
|
||||
|
||||
elif type is None:
|
||||
returned_data["type"] = "error"
|
||||
returned_data["error"] = "No request type/data specified."
|
||||
return returned_data
|
||||
|
||||
else:
|
||||
returned_data["type"] = "error"
|
||||
returned_data["error"] = "Incorrect request type specified."
|
||||
return returned_data
|
||||
|
||||
|
||||
return returned_data
|
||||
|
|
Loading…
Add table
Reference in a new issue