Skip to content

Conversation

@DeepDiver1975
Copy link
Member

@DeepDiver1975 DeepDiver1975 commented Jul 31, 2017

Description

Fix short coming of new chunking implementation -

Related Issue

fixes #26988

Motivation and Context

Behave properly ...

How Has This Been Tested?

Tested with the cli tool as shipped in apps/dav/bin

Please test on various browsers

  • chrome
  • firefox
  • ie
  • edge
  • safari

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@PVince81
Copy link
Contributor

PVince81 commented Aug 1, 2017

@DeepDiver1975 a few weeks ago I was wondering whether X-OC-Mtime on the final move was considered with new chunking. A local test showed that it was considered. But now in this PR you've added extra code for this. I suspect that the reason it worked was maybe that the final MOVE does a Sabre\File::put() operation with the data which itself contains the X-OC-Mtime handling. If we leave your PR as is, we'll end up touching the file twice.

We can't easily move away from 'Sabre\File::put()` due to the part file and hooks logic there. Maybe need some kind of flag ?

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, some minor problem with mtime touching that happens twice.

See comments.

Integration tests will tell whether chunking still works.

Would be good to add integration tests for X-OC-Total-Size.

return;
}

$mTime = $this->server->httpRequest->getHeader('X-OC-mtime');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no more sanitize?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in Node::touch

throw new BadRequest('Http header X-OC-Total-Size is missing');
}
$actualSize = $this->sourceNode->getSize();
if ($expectedSize != $actualSize) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strict !==

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the header is a string and I dont want to cast it to an int due to 32/64 bit nightmare

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does PHP do internally ? whatever PHP does by itself could be even worse ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you insist on keeping it, please add a PHP comment to justify this exception for not respecting the coding style

@DeepDiver1975
Copy link
Member Author

@DeepDiver1975 a few weeks ago I was wondering whether X-OC-Mtime on the final move was considered with new chunking. A local test showed that it was considered. But now in this PR you've added extra code for this. I suspect that the reason it worked was maybe that the final MOVE does a Sabre\File::put() operation with the data which itself contains the X-OC-Mtime handling. If we leave your PR as is, we'll end up touching the file twice.

I'll retest this scenario .... THX for the hint

@DeepDiver1975 DeepDiver1975 force-pushed the verify-chunking-total-size branch from deb9230 to 04088ca Compare August 1, 2017 07:58
@DeepDiver1975 DeepDiver1975 changed the title Handle X-OC-Total-Size and X-OC-MTime in new chunking Handle X-OC-Total-Size in new chunking Aug 1, 2017
@DeepDiver1975 DeepDiver1975 force-pushed the verify-chunking-total-size branch from 04088ca to 1583ab8 Compare August 1, 2017 07:59
@DeepDiver1975
Copy link
Member Author

aaaaargh ... Jenkins was restarted? 💣

@guruz
Copy link
Contributor

guruz commented Aug 1, 2017

logic wise the code looks ok to me. I haven't tested it though and I don't know why the test fails
I guess it is ok to mandate X-OC-Total-Size. But then you could also mandate X-OC-Mtime?

@DeepDiver1975
Copy link
Member Author

I haven't tested it though and I don't know why the test fails

tests are failing because X-OC-Total-Size is missing in the tests.

Is X-OC-Total-Size considered mandatory?

@ogoffart
Copy link

ogoffart commented Aug 2, 2017

Hold on! I just checked the client source and the header is called OC-Total-Length (No X-, and Length).
Also, we only sent this header from MOVE since the client 2.3.2, so the version 2.3.0 and 2.3.1 would break if we make the header mandatory. Hence it should not be mandatory.

EDIT: "Length" and not Lenght, of course

@DeepDiver1975
Copy link
Member Author

Hold on! I just checked the client source and the header is called OC-Total-Lenght (No X-, and Lenght).

the server code in the old chunking used OC-Total-Length - are you sure about the twisted chars?
Can we correct this? Kind of peinlich ....

@ogoffart
Copy link

ogoffart commented Aug 2, 2017

Yes, we re-used the same header on purpose.

@DeepDiver1975 DeepDiver1975 force-pushed the verify-chunking-total-size branch from 1583ab8 to 095e0e2 Compare August 2, 2017 07:39
@DeepDiver1975 DeepDiver1975 changed the title Handle X-OC-Total-Size in new chunking Handle OC-Total-Length in new chunking Aug 2, 2017
@DeepDiver1975
Copy link
Member Author

jenkins green - please test @SamuAlfageme @ogoffart @guruz

@guruz
Copy link
Contributor

guruz commented Aug 2, 2017

We even have the wrong changelog :-)
Size vs Length

guruz@mgmacbookpro mirall $ git grep -i 'Total-'
ChangeLog:* Improve compatibility with server 10.0 (#5691, X-OC-Total-Size)
csync/ChangeLog:  * Add OC-Total-Length header for better quota handling.
src/libsync/propagateuploadng.cpp:    headers["OC-Total-Length"] = QByteArray::number(_item->_size);
src/libsync/propagateuploadng.cpp:        headers["OC-Total-Length"] = QByteArray::number(fileSize);
src/libsync/propagateuploadv1.cpp:    headers["OC-Total-Length"] = QByteArray::number(fileSize);

@mrow4a
Copy link
Contributor

mrow4a commented Aug 3, 2017

@DeepDiver1975 will have a look

@guruz
Copy link
Contributor

guruz commented Aug 4, 2017

@mrow4a To clarify: The wrong size message needs to be displayed, not the "The computed checksum does not match the one received from the client.".

(So actually this issue is not sooo important as the client sends a checksum anyway ;-) )

@PVince81
Copy link
Contributor

PVince81 commented Aug 7, 2017

restarted CI job

@PVince81
Copy link
Contributor

PVince81 commented Aug 8, 2017

Would be good to adjust the integration tests about new chunking too to also send this header

@PVince81
Copy link
Contributor

PVince81 commented Aug 8, 2017

Integration tests to add:

  • send the wrong total size and verify that the upload failed
  • send the correct total size and verify that the upload succeeded

@DeepDiver1975 DeepDiver1975 force-pushed the verify-chunking-total-size branch from 095e0e2 to 9e31de0 Compare August 10, 2017 10:23
@DeepDiver1975
Copy link
Member Author

tested with Chromium Version 60.0.3112.78

@DeepDiver1975
Copy link
Member Author

tested with firefox 53.0 (64-bit)

@DeepDiver1975 DeepDiver1975 force-pushed the verify-chunking-total-size branch from 9e31de0 to 87b4929 Compare August 11, 2017 10:08
if (mtime) {
headers['X-OC-Mtime'] = mtime / 1000;
}
if (size) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would exclude the size "0" but then the chunking code isn't triggered for such sizes, so it's ok

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look fine 👍

@individual-it
Copy link
Member

tested with IE & Safari both are sending "OC-Total-Length" coirrectly

@PVince81
Copy link
Contributor

well, and also fixes a critical bug when you upload a file with new chunking in IE11 which results in EPOCH being set as mtime

@PVince81 PVince81 added the p1-urgent Critical issue, need to consider hotfix with just that issue label Aug 11, 2017
@DeepDiver1975
Copy link
Member Author

what about edge? does it work there as well? @phil-davis @individual-it THX

@phil-davis
Copy link
Contributor

Edge on Win10 laptop with current August "patch Tuesday" patches all applied:
oC server on Ubuntu VM PHP dev server running core master:

Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-AU, en-US; q=0.8, en; q=0.6, ne-NP; q=0.4, ne; q=0.2
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 0
Cookie: ocr6rsb60140=9m02hs1jeq22592nvbju4438j1; oc_sessionPassphrase=ba1k5GOeSzLVJVIU%2BS6OZ31lCrpxrgPSjPqHM%2F469yMMlJBSZm3xaYdbzgsuvREXO%2BzJyDOtk1n18U%2BZHPGiG4%2FwajB8tMB9u%2FmG3VXHkVXRT7xMs4qpLaIWbTZGNX6H
Destination: http://10.49.209.23:8080/remote.php/dav/files/admin/LION_Title_01_01.mp4
Host: 10.49.209.23:8080
requesttoken: ZhcOLwMYHAJnFhgJYHANTQA5EFd8WwQWfEULdS5QPmA=:MdDafpOkHr7x9CObkiu9LbJs1umGvaHS9jRzHh6Teac=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
X-OC-Mtime: NaN
X-Requested-With: XMLHttpRequest

oC server on Ubuntu VM PHP dev server running core verify-chunking-total-size branch (this code):

Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-AU, en-US; q=0.8, en; q=0.6, ne-NP; q=0.4, ne; q=0.2
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 0
Cookie: ocr6rsb60140=9m02hs1jeq22592nvbju4438j1; oc_sessionPassphrase=ba1k5GOeSzLVJVIU%2BS6OZ31lCrpxrgPSjPqHM%2F469yMMlJBSZm3xaYdbzgsuvREXO%2BzJyDOtk1n18U%2BZHPGiG4%2FwajB8tMB9u%2FmG3VXHkVXRT7xMs4qpLaIWbTZGNX6H
Destination: http://10.49.209.23:8080/remote.php/dav/files/admin/LION_Title_01_01.mp4
Host: 10.49.209.23:8080
OC-Total-Length: 1443516495
requesttoken: fRcSIVFYYwJoJW0wMmVyFi0lPSd8XDcsO1wHQioCJAA=:VdXo400kGABAkV09FuXILeyIvlapr3R3gZ2u+eybLxE=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393
X-Requested-With: XMLHttpRequest

OC-Total-Length is good - the size of the movie uploaded.
X-OC-Mtime: NaN has disappeared - without this PR the file gets 1 Jan 1970 date, with this PR the file gets the current date-time??? But when I do it in Chrome on Win10 (both before and with the PR) it sends X-OC-Mtime: 1487326866

@PVince81
Copy link
Contributor

So this is ready for merge after CI ?

@DeepDiver1975 can you prepare the stable10 PR in advance ? Thanks

@DeepDiver1975
Copy link
Member Author

So this is ready for merge after CI ?

yes

@DeepDiver1975 can you prepare the stable10 PR in advance ? Thanks

done

@lock
Copy link

lock bot commented Aug 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3 - To Review p1-urgent Critical issue, need to consider hotfix with just that issue status/STALE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChunkingNG: Missing chunks are silently ignored

9 participants