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

Chunk upload for GDrive #23323

Merged
merged 2 commits into from
Mar 21, 2016
Merged

Chunk upload for GDrive #23323

merged 2 commits into from
Mar 21, 2016

Conversation

PVince81
Copy link
Contributor

Instead of storing the WHOLE file in memory in a PHP variable, use the
library's chunk upload support.

  • TEST: upload small file (less than a chunk)
  • TEST: upload big file (more than a chunk), about 62MB
  • TEST: upload+overwrite small file (less than a chunk)
  • TEST: upload+overwrite big file (more than a chunk), about 62MB
  • TEST: run GDrive unit tests

Fixes #21357 (upload part)

@icewind1991 @LukasReschke @nickvergessen @schiesbn

Instead of storing the WHOLE file in memory in a PHP variable, use the
library's chunk upload support.
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @Xenopathic, @MTGap and @icewind1991 to be potential reviewers

@PVince81
Copy link
Contributor Author

Okay, weird stuff happening with the new calls:

........EE..................................F..............F..F.. 65 / 80 ( 81%)
FF..F..........                                                   80 / 80 (100%)

Time: 10.27 minutes, Memory: 65.75Mb

There were 2 errors:

1) Test\Files\Storage\Google::testGetPutContents with data set #0 ('/srv/www/htdocs/owncloud/test...em.txt')
Google_Service_Exception: Error calling PUT https://www.googleapis.com/upload/drive/v2/files/0B969ZNfFU5SZM25iMTVyeFVMRDA?uploadType=resumable&upload_id=AEnB2UquUle0VjFmdeq7igkWXKa6eP5aZLnMGO9IJ_8ZOVjWINxqYb_fyUstCGSu1MFMO10b5rReHRedR5MKLH1I3nXawzuRPg: (400) Failed to parse Content-Range header.

/srv/www/htdocs/owncloud/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php:79
/srv/www/htdocs/owncloud/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php:185
/srv/www/htdocs/owncloud/apps/files_external/lib/google.php:532
/srv/www/htdocs/owncloud/lib/private/files/stream/close.php:103
/srv/www/htdocs/owncloud/lib/private/files/storage/common.php:192
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:143

2) Test\Files\Storage\Google::testGetPutContents with data set #1 ('/srv/www/htdocs/owncloud/test...ig.txt')
Google_Service_Exception: Error calling PUT https://www.googleapis.com/upload/drive/v2/files/0B969ZNfFU5SZM25iMTVyeFVMRDA?uploadType=resumable&upload_id=AEnB2UrEZgu7tYJJrvr0jnV--JTFdRs4AGajHTM-55CyjYby7xoeiWLhYc4wCZlddiLVnaLKtLl9k38Ozhnp_DbmjMMXK2R1hw: (400) Failed to parse Content-Range header.

/srv/www/htdocs/owncloud/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/REST.php:79
/srv/www/htdocs/owncloud/apps/files_external/3rdparty/google-api-php-client/src/Google/Http/MediaFileUpload.php:185
/srv/www/htdocs/owncloud/apps/files_external/lib/google.php:532
/srv/www/htdocs/owncloud/lib/private/files/stream/close.php:103
/srv/www/htdocs/owncloud/lib/private/files/storage/common.php:192
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:143

--

There were 6 failures:

1) Test\Files\Storage\Google::testStat
Failed asserting that false is true.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:288

2) Test\Files\Storage\Google::testRenameOverWriteDirectory
target/test1.txt has not been overwritten
Failed asserting that false matches expected 'foo'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:489

3) Test\Files\Storage\Google::testCopyOverWriteDirectory
Failed asserting that true is false.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:540

4) Test\Files\Storage\Google::testCopyFromSameStorage with data set #0 ('/source.txt', '/target.txt')
Expected /target.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

5) Test\Files\Storage\Google::testCopyFromSameStorage with data set #1 ('/source.txt', '/target with space.txt')
Expected /target with space.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

6) Test\Files\Storage\Google::testCopyFromSameStorage with data set #4 ('/source.txt', '/tärgét.txt')
Expected /tärgét.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

FAILURES!
Tests: 80, Assertions: 407, Errors: 2, Failures: 6.

@PVince81
Copy link
Contributor Author

Okay, got it. The problem is when writing/updating a file to zero bytes. The API doesn't like empty chunks.

This will need a separate code path to simply store the file.

@PVince81
Copy link
Contributor Author

Changed the code to only use chunks when needed.

Test result is like master:

............................................F..............F..F.. 65 / 80 ( 81%)
FF..F..........                                                   80 / 80 (100%)

Time: 8.95 minutes, Memory: 56.00Mb

There were 6 failures:

1) Test\Files\Storage\Google::testStat
Failed asserting that false is true.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:288

2) Test\Files\Storage\Google::testRenameOverWriteDirectory
target/test1.txt has not been overwritten
Failed asserting that false matches expected 'foo'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:489

3) Test\Files\Storage\Google::testCopyOverWriteDirectory
Failed asserting that true is false.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:540

4) Test\Files\Storage\Google::testCopyFromSameStorage with data set #0 ('/source.txt', '/target.txt')
Expected /target.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

5) Test\Files\Storage\Google::testCopyFromSameStorage with data set #1 ('/source.txt', '/target with space.txt')
Expected /target with space.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

6) Test\Files\Storage\Google::testCopyFromSameStorage with data set #4 ('/source.txt', '/tärgét.txt')
Expected /tärgét.txt to be a copy of /srv/www/htdocs/owncloud/tests/data/lorem.txt
Failed asserting that false matches expected 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'.

/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:196
/srv/www/htdocs/owncloud/tests/lib/files/storage/storage.php:570

FAILURES!
Tests: 80, Assertions: 409, Failures: 6.

I'll do a manual retest:

  • TEST: upload empty file
  • TEST: upload+overwrite empty file
  • TEST: upload small file (less than a chunk)
  • TEST: upload big file (more than a chunk), about 62MB
  • TEST: upload+overwrite small file (less than a chunk)
  • TEST: upload+overwrite big file (more than a chunk), about 62MB

@PVince81
Copy link
Contributor Author

The unit tests are the same that were expected to fail like in #22481

Please review @icewind1991 @LukasReschke @schiesbn @Xenopathic

@PVince81
Copy link
Contributor Author

@karlitschek backport to 9.0.1 ? This solves memory issues when uploading because the old impl stored the whole file in memory.

@karlitschek
Copy link
Contributor

good catch. please backport

@PVince81
Copy link
Contributor Author

stable9: #23361

@PVince81
Copy link
Contributor Author

@icewind1991 @nickvergessen @DeepDiver1975 please review.
I already tested this several times, so a glance at the code should be fine. (I know how painful it is to setup GDrive)

@PVince81
Copy link
Contributor Author

@SergioBertolinSG

@icewind1991
Copy link
Contributor

Code looks good 👍

@SergioBertolinSG
Copy link
Contributor

Works fine and seems faster than before 👍

DeepDiver1975 added a commit that referenced this pull request Mar 21, 2016
@DeepDiver1975 DeepDiver1975 merged commit 736b80f into master Mar 21, 2016
@DeepDiver1975 DeepDiver1975 deleted the gdrive-chunkupload branch March 21, 2016 17:02
@lock
Copy link

lock bot commented Aug 6, 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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stream upload/download for GDrive
7 participants