Skip to content

[stable34] fix(encryption): Correctly report size for zero-byte encrypted files - #62780

Open
backportbot[bot] wants to merge 3 commits into
stable34from
backport/60070/stable34
Open

[stable34] fix(encryption): Correctly report size for zero-byte encrypted files#62780
backportbot[bot] wants to merge 3 commits into
stable34from
backport/60070/stable34

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 3, 2026

Copy link
Copy Markdown

Backport of PR #60070

cuppett and others added 3 commits August 3, 2026 09:28
Files with 0 bytes no longer incorrectly report as 8192 bytes. Widens unencryptedSize
to ?int, fixes verifyUnencryptedSize to compare against header size instead of 0,
and corrects Scanner to populate unencrypted_size on initial upload.

Assisted-by: ClaudeCode:claude-opus-4-6
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Stephen Cuppett <steve@cuppett.com>
…stency

Apply come-nc's reviewer suggestions on Scanner.php:
- Simplify cached unencrypted_size skip condition to explicit == 0 check
- Remove redundant !isset guard on new-file path

Fix remaining > 0 / !== 0 guards that treated zero as "no unencrypted_size":
- FileInfo constructor: use encrypted flag for rawSize (getSize(false) path)
- FileInfo::addSubEntry: use encrypted flag for sub-mount accumulation
- Cache::calculateFolderSizeInner: use encrypted column instead of > 0

Add tests covering zero-byte encrypted file scenarios:
- FileInfoTest: getSize(true/false) for zero-byte encrypted files
- CacheTest: getUnencryptedSize and calculateFolderSize with encrypted=1,size=0
- EncryptionTest: verifyUnencryptedSize data provider cases for header-only files

Assisted-by: ClaudeCode:claude-opus-4-6
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Stephen Cuppett <scuppett@redhat.com>
…Byte

Add a second encrypted child with unencrypted_size=100 so the write-back
gate in calculateFolderSizeInner ($unencryptedMax > 0) actually opens.
The original single zero-byte child left the gate closed, meaning the
test passed against the DB default rather than the computed value.

With two children the assertion distinguishes the fixed code (result: 100)
from the old buggy code (result: 8292, falling back to on-disk size for
the zero-byte child).

Assisted-by: ClaudeCode:claude-opus-4-6
Signed-off-by: Stephen Cuppett <scuppett@redhat.com>
@backportbot
backportbot Bot requested a review from a team as a code owner August 3, 2026 09:28
@backportbot
backportbot Bot requested review from come-nc, cuppett, icewind1991, leftybournes, miaulalala, nfebe and sorbaugh and removed request for a team August 3, 2026 09:28
@backportbot backportbot Bot added this to the Nextcloud 34.0.3 milestone Aug 3, 2026
@cuppett
cuppett enabled auto-merge August 3, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants