owncloud / ocis

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

download may return internal server error #10526

Closed butonic closed 1 week ago

butonic commented 2 weeks ago

The jsoncs3 sharing implementation relies on proper handling of IfNoneMatch and IfMatch headers.

Unfortunately, there is a codepa that might return a 500 server error when the IfNoneMatch header is set:

  1. the datatx GetOrHeadFile implementation calls fs.GetMD
  2. the etag changed as required bd IfNoneMatch
  3. someone else updates the file
  4. the fs.Downcload file fails because the etag new changed from the previous GetMD call.

This causes the jsoncs3 share manager to error out. The jsoncs3 code just seems to return an error for the request but I fear that corrupts the share cache which would be metadata loss. During load testing this prevented any further shares to be created, because the received.json file for the recipient group had somehow been deleted.

I intend to add a new interface that can be used by GetOrHeadFile to get athe metadata and a callback that will return the corresponding Reader

type ConsistentDownloader interface {
    // ConsistentDownload returns the metadata for a resource and a callback to get the content stream matching the etag
    ConsistentDownload(ctx context.Context, ref *provider.Reference) (*provider.ResourceInfo, func(ctx context.Context, ref *provider.Reference) (io.ReadCloser, error), error)
}