quotient-im / Quaternion

A Qt-based IM client for Matrix
https://matrix.org/ecosystem/clients/quaternion/
GNU General Public License v3.0
642 stars 107 forks source link

Corrupted PNG with authorized download #825

Open ghost opened 2 years ago

ghost commented 2 years ago

Description

Downloading files with a retried auth seems to yield corrupted files sometimes. Image of the inspected header attached. screenshot273

I suspect what is happening is that Quaternion tries to load the first image, saves the error code to the file despite the unauthorized http error and then on the second auth run assumes the file is a partial download. I have not checked the code to confirm this so I could be wrong easily.

On second images then quaternion already knows the repo requires auth so this doesn't happen again. Log:

quotient.jobs: 401 <- GET https://nheko-im.neko.dev/_matrix/media/r0/download/tchncs.de/04fedbd08af4eacafe63beeb94b4369b352cc801
quotient.jobs: "DownloadFileJob" status Unauthorised: Host requires authentication
quotient.jobs: "DownloadFileJob" re-running with authentication
[...]
quotient.jobs: 200 <- GET https://nheko-im.neko.dev/_matrix/media/r0/download/tchncs.de/04fedbd08af4eacafe63beeb94b4369b352cc801
qrc:/qml/ImageContent.qml:10:5: QML Image: Error decoding: file:///boot/system/cache/tmp/04fedbd08af4eacafe63beeb94b4369b352cc801_6f61ca6b9z091.png: Unsupported image format

Steps to reproduce

Use a server with auth, seems to happen with some media only edit: probably only the first media download of the session is affected by this

Version information

Haiku hrev56122+7 Quaternion v0.0.95.1 Qt 5.15.2-8 QtHaikuPlugins 5.15.2.21-1

KitsuneRal commented 1 year ago

Does it still happen or not any more? There were quite a few changes around the relevant code.