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

compare cached filesize on download #34232

Merged
merged 1 commit into from
Dec 3, 2022

Conversation

ArtificialOwl
Copy link
Member

@ArtificialOwl ArtificialOwl commented Sep 24, 2022

  • need more test on specific storages (external, s3, ...)

  • might need a refresh of parent[s] folder cached data

  • TEST: with master-key encryption

@ArtificialOwl ArtificialOwl added the 2. developing Work in progress label Sep 24, 2022
@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch from 6bacebf to 646dc24 Compare September 24, 2022 11:42
@szaimen szaimen added this to the Nextcloud 26 milestone Sep 26, 2022
@PVince81
Copy link
Member

does the scanner not automatically update the parent folder's sizes ?
if not, maybe try with writeUpdate like in https://github.com/nextcloud/server/pull/33566/files#diff-64a02ee1149d33d0747360694c2abf4ef1bdbfc379b4bb40f76c22b5b1fc06d9R1011

@icewind1991
Copy link
Member

The scanner does not update parent sizes on it's own

@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch 2 times, most recently from e2bdfd1 to 3b22c7c Compare September 30, 2022 10:49
@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch from 3b22c7c to 04a0f9c Compare September 30, 2022 10:53
@ArtificialOwl ArtificialOwl added the 3. to review Waiting for reviews label Sep 30, 2022
@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch 6 times, most recently from 6152063 to acaafa5 Compare October 2, 2022 08:46
@ArtificialOwl
Copy link
Member Author

@PVince81

drone issue looks unrelated. tested on encrypted file, looks good on my side. might need more test !?

@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch from acaafa5 to 2980e68 Compare October 2, 2022 12:41
@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

@icewind1991 icewind1991 force-pushed the fix/noid/refresh-filesize-on-conflict branch 3 times, most recently from cda568a to 9ab4e07 Compare October 10, 2022 15:59
@icewind1991
Copy link
Member

changed it to pass the stream size up through the seekable wrapper

@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

@nextcloud nextcloud deleted a comment from github-actions bot Oct 10, 2022
@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
1 queries added

= /remote.php/dav/files/test
= /remote.php/dav/files/test/test.txt
= /remote.php/dav/files/test/many_files
≠ /remote.php/dav/files/test/new_file.txt with 1 queries added
  - UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3, "size" = CASE WHEN "size" > '-1' THEN MAX("size" + :dcValue4, :dcValue5) ELSE "size" END WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "mtime" = MAX("mtime", :dcValue1), "etag" = :dcValue3 WHERE ("storage" = :dcValue2) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1'))
  + UPDATE "oc_filecache" SET "size" = MAX("size" + :dcValue1, :dcValue2) WHERE ("storage" = :dcValue3) AND ("path_hash" IN ('d41d8cd98f00b204e9800998ecf8427e', '45b963397aa40d4a0063e0d85e4fe7a1')) AND ("size" > '-1')
= /remote.php/dav/files/test/new_file.txt

@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch 2 times, most recently from 0563952 to 0eed192 Compare October 13, 2022 12:54
@ArtificialOwl
Copy link
Member Author

squashed and rebased; also adding a return false if handle is false to keep backward compat on calls to read()

working on my side (local files, s3 primary, encrypted)

@PVince81 PVince81 removed the 2. developing Work in progress label Oct 13, 2022
@ArtificialOwl ArtificialOwl force-pushed the fix/noid/refresh-filesize-on-conflict branch from 0eed192 to 20cf73f Compare October 13, 2022 18:55
@PVince81
Copy link
Member

what's missing to get this merged ? @ArtificialOwl @icewind1991

also see my comments

lib/private/Files/ObjectStore/ObjectStoreStorage.php Outdated Show resolved Hide resolved
lib/private/Files/Stream/SeekableHttpStream.php Outdated Show resolved Hide resolved
@PVince81 PVince81 requested a review from CarlSchwan October 25, 2022 15:34
@PVince81
Copy link
Member

PVince81 commented Nov 4, 2022

@icewind1991 can you do the 2nd review ?

@ArtificialOwl
Copy link
Member Author

So ran some manual test....

All tests are made on a 25.0.1 patched with 34232.diff

  • s3

    • internal download
    • internal folder.zip download => size is fixed, download of the full folder is ok, but top folder size is not updated
    • public share => size is updated, but download needs to be restarted
    • groupfolder (including public share, internal folder.zip download)
    • internal shared file
    • Desktop client
  • local filesystem

    • internal download
    • internal folder.zip download => size is fixed, download of the full folder is ok, but top folder size is not updated
    • public share
    • groupfolder (including public share, public folder.zip download)
    • internal shared file
    • Desktop client
  • not working with encryption

@ArtificialOwl
Copy link
Member Author

testing on encrypted local filesystem for data/:

  • fresh install of nc25.0.1
  • enable encryption
  • enable default server encryption app
  • master key enabled by default
  • encrypt-all
  • creating new text file
  • stored size in filecache is the one of the clear version, unencrypted_size is 0
  • edit test file
  • file size in filecache is updated with clear version, unencrypted_size still 0
  • editing size value in filecache (with lower value)
  • downloaded file is crop after n chars, which is the new edited value for size in filecache
  • editing size value in filecache (with slightly higher value)
  • downloaded file is fine and correct size on my disk
  • editing size value in filecache (with slightly higher value)
  • cannot download file, click will open a new empty tab in firefox
  • unencrypted_size is still 0

@PVince81
Copy link
Member

as discussed, @ArtificialOwl will retest on master to see if the encryption behavior is the same.

if this PR doesn't affect encryption the let's ship it as is

@ArtificialOwl
Copy link
Member Author

as discussed, @ArtificialOwl will retest on master to see if the encryption behavior is the same.

if this PR doesn't affect encryption the let's ship it as is

On encrypted FS, same test failed the exact same way without the patch

@PVince81
Copy link
Member

ok, so this PR doesn't affect encryption behavior, let's merge it

@PVince81
Copy link
Member

linter not happy though, please have a look @ArtificialOwl

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants