Skip to content

Commit 8d9a26f

Browse files
[ENG-8401] Earlier preprint versions download the current file (#11245)
* fixed earlier version download the newest version file * fixed tests
1 parent 61a072f commit 8d9a26f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

addons/base/views.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,17 @@ def persistent_file_download(auth, **kwargs):
10061006
file = BaseFileNode.active.filter(_id=id_or_guid).first()
10071007
if not file:
10081008
guid = Guid.load(id_or_guid)
1009-
if guid:
1010-
referent = guid.referent
1011-
file = referent.primary_file if type(referent) is Preprint else referent
1012-
else:
1009+
if not guid:
10131010
raise HTTPError(http_status.HTTP_404_NOT_FOUND, data={
10141011
'message_short': 'File Not Found',
10151012
'message_long': 'The requested file could not be found.'
10161013
})
1014+
1015+
file = guid.referent
1016+
if type(file) is Preprint:
1017+
referent, _ = Guid.load_referent(id_or_guid)
1018+
file = referent.primary_file
1019+
10171020
if not file.is_file:
10181021
raise HTTPError(http_status.HTTP_400_BAD_REQUEST, data={
10191022
'message_long': 'Downloading folders is not permitted.'

0 commit comments

Comments
 (0)