owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.4k stars 183 forks source link

Uploading a 0kb file to a secret file drop results in an error however the file appears in the folder multiple times. #10469

Open nicholas-wilson-au opened 1 week ago

nicholas-wilson-au commented 1 week ago

Describe the bug

Uploading a 0kb file to a secret file drop results in an error however the file appears in the folder multiple times.

Steps to reproduce

  1. Create 0kb file
  2. Create space and set up a public link as a secret file drop
  3. Try to upload the file to the secret file drop. Error is seen.
  4. Look in the space and check for file. Multiple copies are there.

Expected behavior

A successful upload of a single file or an error saying the file is empty.

Actual behavior

An error is shown saying upload failed but the upload was successful.

Setup

https://ocis.ocis-keycloak.rolling.owncloud.works/

JammingBen commented 1 day ago

I'm moving this to the ocis repo because I think Web is handling things correctly. When uploading a 0 byte file, the server is missing the Location header in the response.

In a regular context Uppy will retry the exact same request again. The server includes the Location header the second time. In a public link context with only upload permissions (= file drop) however, the server never responds with a location header.

2403905 commented 1 day ago

@JammingBen How the Web uses the location in this case? The zero-byte file is simply created, it is not going to the tus.

https://github.com/cs3org/reva/blob/b7d7c42e082a5e7784e2545abf768bb0de0b103e/internal/http/services/owncloud/ocdav/tus.go#L190

JammingBen commented 15 hours ago

The underlying lib we use (Uppy) does something with this header, I can't say what exactly. I'd need to check the vendor code.

But why is oCIS sending a Location header on the second try then? Isn't it possible to always send it?

JammingBen commented 10 hours ago

I did some further debugging. As mentioned above, the issue is that the server doesn't send a Location header in the response because zero byte files are simply being touched without tus being involved.

I tried to handle this exception in Web but it's not that easy. Web is assuming that all file uploads are being handled via tus (when enabled) and therefore expects the server to follow the tus protocol under any circumstance. If this isn't the case, it might fail. IMO it's up to the server to provide a clean API here.

cc @2403905 @butonic