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

[fix] prevent creating a phantom BaseFileNode with Guid #10092

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,6 @@ def addon_view_or_download_file(auth, path, provider, **kwargs):
)
)

# There's no download action redirect to the Ember front-end file view and create guid.
if action != 'download':
if isinstance(target, Node) and waffle.flag_is_active(request, features.EMBER_FILE_PROJECT_DETAIL):
guid = file_node.get_guid(create=True)
return redirect(f'{settings.DOMAIN}{guid._id}/')
if isinstance(target, Registration) and waffle.flag_is_active(request, features.EMBER_FILE_REGISTRATION_DETAIL):
guid = file_node.get_guid(create=True)
return redirect(f'{settings.DOMAIN}{guid._id}/')

if version is None:
# File is either deleted or unable to be found in the provider location
# Rollback the insertion of the file_node
Expand Down Expand Up @@ -799,6 +790,15 @@ def addon_view_or_download_file(auth, path, provider, **kwargs):
else:
transaction.savepoint_commit(savepoint_id)

# There's no download action redirect to the Ember front-end file view and create guid.
if action != 'download':
if isinstance(target, Node) and waffle.flag_is_active(request, features.EMBER_FILE_PROJECT_DETAIL):
guid = file_node.get_guid(create=True)
return redirect(f'{settings.DOMAIN}{guid._id}/')
if isinstance(target, Registration) and waffle.flag_is_active(request, features.EMBER_FILE_REGISTRATION_DETAIL):
guid = file_node.get_guid(create=True)
return redirect(f'{settings.DOMAIN}{guid._id}/')

# TODO clean up these urls and unify what is used as a version identifier
if request.method == 'HEAD':
return make_response(('', http_status.HTTP_302_FOUND, {
Expand Down