consistency: accept 'file_id' and 'hash' where 'file_ids'/'hashes' is accepted
This commit is contained in:
parent
33187d7561
commit
2a352104de
|
@ -1176,7 +1176,9 @@ Required Headers:
|
|||
Arguments (in JSON):
|
||||
:
|
||||
* `page_key`: (the page key for the page you wish to add files to)
|
||||
* `file_id`: (selective, a numerical file id)
|
||||
* `file_ids`: (selective, a list of numerical file ids)
|
||||
* `hash`: (selective, a hexadecimal SHA256 hash)
|
||||
* `hashes`: (selective, a list of hexadecimal SHA256 hashes)
|
||||
|
||||
You need to use either file_ids or hashes. The files they refer to will be appended to the given page, just like a thumbnail drag and drop operation. The page key is the same as fetched in the [/manage\_pages/get\_pages](#manage_pages_get_pages) call.
|
||||
|
@ -1407,7 +1409,9 @@ Required Headers: n/a
|
|||
|
||||
Arguments (in percent-encoded JSON):
|
||||
:
|
||||
* `file_id`: (selective, a numerical file id)
|
||||
* `file_ids`: (selective, a list of numerical file ids)
|
||||
* `hash`: (selective, a hexadecimal SHA256 hash)
|
||||
* `hashes`: (selective, a list of hexadecimal SHA256 hashes)
|
||||
* `only_return_identifiers`: true or false (optional, defaulting to false)
|
||||
* `detailed_url_information`: true or false (optional, defaulting to false)
|
||||
|
|
|
@ -2196,9 +2196,15 @@ class HydrusResourceClientAPIRestrictedGetFilesFileMetadata( HydrusResourceClien
|
|||
|
||||
try:
|
||||
|
||||
if 'file_ids' in request.parsed_request_args:
|
||||
if 'file_ids' in request.parsed_request_args or 'file_id' in request.parsed_request_args:
|
||||
|
||||
file_ids = request.parsed_request_args.GetValue( 'file_ids', list, expected_list_type = int )
|
||||
if 'file_ids' in request.parsed_request_args:
|
||||
|
||||
file_ids = request.parsed_request_args.GetValue( 'file_ids', list, expected_list_type = int )
|
||||
|
||||
else:
|
||||
|
||||
file_ids = [ request.parsed_request_args.GetValue( 'file_id', int ) ]
|
||||
|
||||
request.client_api_permissions.CheckPermissionToSeeFiles( file_ids )
|
||||
|
||||
|
@ -2211,11 +2217,17 @@ class HydrusResourceClientAPIRestrictedGetFilesFileMetadata( HydrusResourceClien
|
|||
media_results = HG.client_controller.Read( 'media_results_from_ids', file_ids, sorted = True )
|
||||
|
||||
|
||||
elif 'hashes' in request.parsed_request_args:
|
||||
elif 'hashes' in request.parsed_request_args or 'hash' in request.parsed_request_args:
|
||||
|
||||
request.client_api_permissions.CheckCanSeeAllFiles()
|
||||
|
||||
hashes = request.parsed_request_args.GetValue( 'hashes', list, expected_list_type = bytes )
|
||||
if 'hashes' in request.parsed_request_args:
|
||||
|
||||
hashes = request.parsed_request_args.GetValue( 'hashes', list, expected_list_type = bytes )
|
||||
|
||||
else:
|
||||
|
||||
hashes = [ request.parsed_request_args.GetValue( 'hash', bytes ) ]
|
||||
|
||||
CheckHashLength( hashes )
|
||||
|
||||
|
@ -2742,7 +2754,15 @@ class HydrusResourceClientAPIRestrictedManagePagesAddFiles( HydrusResourceClient
|
|||
|
||||
page_key = request.parsed_request_args.GetValue( 'page_key', bytes )
|
||||
|
||||
if 'hashes' in request.parsed_request_args:
|
||||
if 'hash' in request.parsed_request_args:
|
||||
|
||||
hashes = [ request.parsed_request_args.GetValue( 'hash', bytes ) ]
|
||||
|
||||
CheckHashLength( hashes )
|
||||
|
||||
media_results = HG.client_controller.Read( 'media_results', hashes, sorted = True )
|
||||
|
||||
elif 'hashes' in request.parsed_request_args:
|
||||
|
||||
hashes = request.parsed_request_args.GetValue( 'hashes', list, expected_list_type = bytes )
|
||||
|
||||
|
@ -2750,6 +2770,12 @@ class HydrusResourceClientAPIRestrictedManagePagesAddFiles( HydrusResourceClient
|
|||
|
||||
media_results = HG.client_controller.Read( 'media_results', hashes, sorted = True )
|
||||
|
||||
elif 'file_id' in request.parsed_request_args:
|
||||
|
||||
hash_ids = [ request.parsed_request_args.GetValue( 'file_id', int ) ]
|
||||
|
||||
media_results = HG.client_controller.Read( 'media_results_from_ids', hash_ids, sorted = True )
|
||||
|
||||
elif 'file_ids' in request.parsed_request_args:
|
||||
|
||||
hash_ids = request.parsed_request_args.GetValue( 'file_ids', list, expected_list_type = int )
|
||||
|
|
Loading…
Reference in New Issue