Properly handle encrypted/plain file size with object storage #22994
Labels
0. Needs triage
Pending check for reproducibility or if it fits our roadmap
bug
feature: encryption (server-side)
feature: object storage
needs info
When using primary object storage we store the size of the bytes written to the storage in the file cache. Since the filecache is reused for the stat call, fetching the file size will lead to the encrypted size being returned in https://github.com/nextcloud/server/blob/master/lib/private/Files/Storage/Wrapper/Encryption.php#L494 instead of the unencrypted one as it would be the case for local storage. Now the filecache has a column unencrypted_size which seems to be never used actually. This will actually cause https://github.com/nextcloud/server/blob/master/lib/private/Files/Storage/Wrapper/Encryption.php#L526 to be called with both size and unencryptedSize being the same, the encrypted size.
While we could go though the whole file to check the signature on the last block this has quite some performance impact, so we'd need a way to either make sure that the unencrypted size is put into the size column (as it is currently done for local storage) or better use the unencrypted_size in general to store this.
Steps to reproduce:
cc @rullzer
The text was updated successfully, but these errors were encountered: