Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oCIS FS: zero size file uploads create a blob entry in upload target #2609

Closed
wkloucek opened this issue Oct 12, 2021 · 3 comments · Fixed by cs3org/reva#2309
Closed

oCIS FS: zero size file uploads create a blob entry in upload target #2609

wkloucek opened this issue Oct 12, 2021 · 3 comments · Fixed by cs3org/reva#2309
Labels
Priority:p3-medium Normal priority Severity:sev2-high operations severely restricted, workaround available Storage:OCIS Storage:S3NG Type:Bug

Comments

@wkloucek
Copy link
Contributor

Describe the bug

Upload a zero size file to oCIS running on oCIS FS.

Steps to reproduce

Steps to reproduce the behavior:

  1. Upload a zero size file using oC Web
  2. Refresh the page

Expected behavior

You see exactly the file you uploaded

Actual behavior

You see the file you uploaded and a file with a UUIDv4.

Setup

oCIS master on e4cc2a5, but same behaviour was on oCIS 1.12.0

@wkloucek wkloucek added Type:Bug Priority:p3-medium Normal priority Severity:sev2-high operations severely restricted, workaround available Storage:S3NG Storage:OCIS labels Oct 12, 2021
@C0rby
Copy link
Contributor

C0rby commented Oct 22, 2021

Bug description

Here we check if the upload size is 0 bytes.
https://github.com/cs3org/reva/blob/582ce36aadccbc962ad01aebe2f0dcba7e790143/pkg/storage/utils/decomposedfs/upload.go#L300-L307

	if !info.SizeIsDeferred && info.Size == 0 {
		...
		err := u.FinishUpload(ctx) <-- Early finish
		...

If that is the case we finish the upload in line 303.

Now we get back to the ocdav handler:
https://github.com/cs3org/reva/blob/582ce36aadccbc962ad01aebe2f0dcba7e790143/internal/http/services/owncloud/ocdav/put.go#L222-L260

	uRes, err := client.InitiateFileUpload(ctx, uReq)
       ...
	httpReq, err := rhttp.NewRequest(ctx, http.MethodPut, ep, r.Body)
	...
	httpReq.Header.Set(datagateway.TokenTransportHeader, token)
	httpRes, err := s.client.Do(httpReq)

Even though the upload was finished already, the ocdav handler doesn't know this and continues with the simple dataprovider, which will eventually end up here:
https://github.com/cs3org/reva/blob/582ce36aadccbc962ad01aebe2f0dcba7e790143/pkg/storage/utils/decomposedfs/upload.go#L58-L72

	upload, err := fs.GetUpload(ctx, ref.GetPath()) <-- fail because no file in uploads directory
	if err != nil {
		// Upload corresponding to this ID was not found.
		...
		metadata := map[string]string{"sizedeferred": "true"}
		uploadIDs, err := fs.InitiateUpload(ctx, ref, 0, metadata) <-- Second initiate upload = UUID file
		...
		if upload, err = fs.GetUpload(ctx, uploadIDs["simple"]); err != nil {
		...

There it will try to get the upload and fail because we never wrote a .info file for the upload. Because of that it will create a new upload in line 65 and then continue to upload the file which we will see as the uuid file.

Possible Solution

We either need to remove the early finish in the NewUpload method or tell the webdav handler that the upload was already finished and not call the simple dataprovider.

@wkloucek
Copy link
Contributor Author

@nikslor
Copy link

nikslor commented Nov 26, 2021

Not sure if it's relevant; I think I also see this when using rclone to sync files to oCIS.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:p3-medium Normal priority Severity:sev2-high operations severely restricted, workaround available Storage:OCIS Storage:S3NG Type:Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants