Link refresh: allow refreshing links for soft-deleted projects.
Since files aren't deleted (yet) when projects are deleted, it can happen that a file is refreshed but then cannot reference a deleted project. By removing the project ID from the PATCH, Eve doesn't have enough info to check this, and it'll work fine.
This commit is contained in:
@@ -467,6 +467,12 @@ def generate_all_links(response, now):
|
|||||||
response['link_expires'] = now + datetime.timedelta(seconds=validity_secs)
|
response['link_expires'] = now + datetime.timedelta(seconds=validity_secs)
|
||||||
|
|
||||||
patch_info = remove_private_keys(response)
|
patch_info = remove_private_keys(response)
|
||||||
|
|
||||||
|
# The project could have been soft-deleted, in which case it's fine to
|
||||||
|
# update the links to the file. However, Eve/Cerberus doesn't allow this;
|
||||||
|
# removing the 'project' key from the PATCH works around this.
|
||||||
|
patch_info.pop('project', None)
|
||||||
|
|
||||||
file_id = ObjectId(response['_id'])
|
file_id = ObjectId(response['_id'])
|
||||||
(patch_resp, _, _, _) = current_app.patch_internal('files', patch_info,
|
(patch_resp, _, _, _) = current_app.patch_internal('files', patch_info,
|
||||||
_id=file_id)
|
_id=file_id)
|
||||||
|
Reference in New Issue
Block a user