aces / Loris

LORIS is a web-accessible database solution for longitudinal multi-site studies.
GNU General Public License v3.0
141 stars 173 forks source link

[imaging_uploader] Invalid error message displayed when an invalid upload is done #9255

Closed nicolasbrossard closed 1 month ago

nicolasbrossard commented 1 month ago

I tried uploading a scan for a non-existent PSCID and got this error message:

Invalid PSCID CAPT0000001 for CandID 657068. Check that you entered the correct PSCID and CandID. The file CAPT0000001_657068_Capture00M_QUE.zip is not of type .tgz, .tar.gz or .zip.

My file was a .zip so the second sentence should not be there. I feel like the ... is not of type .tgz, .tar.gz or .zip sentence is always appended to the real error message.

skarya22 commented 1 month ago

Hi Nicolas,

Do you remember if you actually uploaded a compressed file, or if you uploaded a different type and renamed it to .zip? I tried uploading a zip file and got:

Image

However, when I renamed a png to be .zip, I got: Image

I noticed that the imaging_uploader does not check for the file including the string .zip, it instead checks the actual filetype using mime_content_type

If you can confirm that you just renamed a non-compressed file to .zip, then I believe this is not an issue.

AlexandraLivadas commented 1 month ago

Also, based on the isCompressed documentation, it does not work for zip-based compression. Maybe we should check if this is happening for other file types like .tar.gz

nicolasbrossard commented 1 month ago

@skarya22 I see what you mean. I did rename a random file to .zip, which would explain why I got two error messages displayed in the popup (one for the mismatch in pscid/candid and the other for the invalid file format). This issue can be closed then.

skarya22 commented 1 month ago

@AlexandraLivadas I believe that the "type" for .tar.gz and others also includes the term "zip" such as application/gzip, so I don't think there should be an issue - but worth testing anyway!

AlexandraLivadas commented 1 month ago

Ok I tested and its working for everything. I think we are good to close.