Skip to content

[ENG-8401] Earlier preprint versions download the current file #11245

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

Merged
Merged
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
11 changes: 7 additions & 4 deletions addons/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,14 +1006,17 @@ def persistent_file_download(auth, **kwargs):
file = BaseFileNode.active.filter(_id=id_or_guid).first()
if not file:
guid = Guid.load(id_or_guid)
if guid:
referent = guid.referent
file = referent.primary_file if type(referent) is Preprint else referent
else:
if not guid:
raise HTTPError(http_status.HTTP_404_NOT_FOUND, data={
'message_short': 'File Not Found',
'message_long': 'The requested file could not be found.'
})

file = guid.referent
if type(file) is Preprint:
referent, _ = Guid.load_referent(id_or_guid)
file = referent.primary_file

if not file.is_file:
raise HTTPError(http_status.HTTP_400_BAD_REQUEST, data={
'message_long': 'Downloading folders is not permitted.'
Expand Down
Loading