Skip to content

compare cached filesize on download - #34232

Merged
szaimen merged 1 commit into
masterfrom
fix/noid/refresh-filesize-on-conflict
Dec 3, 2022
Merged

compare cached filesize on download#34232
szaimen merged 1 commit into
masterfrom
fix/noid/refresh-filesize-on-conflict

Conversation

@ArtificialOwl

@ArtificialOwlArtificialOwl commented Sep 24, 2022

Copy link
Copy Markdown
Member
  • need more test on specific storages (external, s3, ...)

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

  • TEST: with master-key encryption

@ArtificialOwlArtificialOwl added the 2. developing Work in progress label Sep 24, 2022
Comment threadapps/dav/lib/Connector/Sabre/File.php Fixed
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch from 6bacebf to 646dc24CompareSeptember 24, 2022 11:42
@szaimenszaimen added this to the Nextcloud 26 milestone Sep 26, 2022
@PVince81

Copy link
Copy Markdown
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

Comment threadapps/dav/lib/Connector/Sabre/File.php Outdated
@icewind1991

Copy link
Copy Markdown
Member

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

Comment threadlib/public/Files/ExpectedFileSizeException.php Fixed
Comment threadlib/public/Files/ExpectedFileSizeException.php Fixed
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch 2 times, most recently from e2bdfd1 to 3b22c7cCompareSeptember 30, 2022 10:49
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch from 3b22c7c to 04a0f9cCompareSeptember 30, 2022 10:53
@ArtificialOwlArtificialOwl added the 3. to review Waiting for reviews label Sep 30, 2022
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch 6 times, most recently from 6152063 to acaafa5CompareOctober 2, 2022 08:46
@ArtificialOwl

Copy link
Copy Markdown
MemberAuthor

@PVince81

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

@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch from acaafa5 to 2980e68CompareOctober 2, 2022 12:41
Comment threadlib/private/Files/ObjectStore/S3ObjectTrait.php Outdated
@github-actions

Copy link
Copy Markdown
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
icewind1991force-pushed the fix/noid/refresh-filesize-on-conflict branch 3 times, most recently from cda568a to 9ab4e07CompareOctober 10, 2022 15:59
@icewind1991

Copy link
Copy Markdown
Member

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

@github-actions

Copy link
Copy Markdown
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

@nextcloudnextcloud deleted a comment from github-actionsBotOct 10, 2022
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Fixed
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Fixed
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Fixed
@github-actions

Copy link
Copy Markdown
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

Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Outdated
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch 2 times, most recently from 0563952 to 0eed192CompareOctober 13, 2022 12:54
@ArtificialOwl

Copy link
Copy Markdown
MemberAuthor

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)

@PVince81PVince81 removed the 2. developing Work in progress label Oct 13, 2022
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Outdated
@ArtificialOwl
ArtificialOwlforce-pushed the fix/noid/refresh-filesize-on-conflict branch from 0eed192 to 20cf73fCompareOctober 13, 2022 18:55
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Fixed
Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Fixed
@PVince81

Copy link
Copy Markdown
Member

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

also see my comments

Comment threadlib/private/Files/ObjectStore/ObjectStoreStorage.php Outdated
Comment threadlib/private/Files/Stream/SeekableHttpStream.php Outdated
@PVince81

Copy link
Copy Markdown
Member

@icewind1991 can you do the 2nd review ?

@ArtificialOwl

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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

@PVince81

Copy link
Copy Markdown
Member

linter not happy though, please have a look @ArtificialOwl

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@ArtificialOwl@PVince81@icewind1991@github-advanced-security@come-nc@szaimen