Skip to content

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

Merged
AndyScherzinger merged 4 commits into
stable33from
backport/60070/stable33
Aug 5, 2026
Merged

[stable33] fix(encryption): Correctly report size for zero-byte encrypted files#62779
AndyScherzinger merged 4 commits into
stable33from
backport/60070/stable33

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 3, 2026

Copy link
Copy Markdown

Backport of #60070

Warning, This backport's changes differ from the original and might be incomplete ⚠️

Todo

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

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

test(encryption): strengthen testCalculateFolderSizeWithEncryptedZeroByte

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>

[skip ci]
@backportbot
backportbot Bot requested review from come-nc, cuppett and miaulalala August 3, 2026 09:28
@backportbot backportbot Bot added this to the Nextcloud 33.0.8 milestone Aug 3, 2026
@cuppett
cuppett marked this pull request as ready for review August 4, 2026 13:00
@cuppett
cuppett requested a review from a team as a code owner August 4, 2026 13:00
@cuppett
cuppett requested review from Altahrim, nfebe and sorbaugh and removed request for a team August 4, 2026 13:00

@cuppett cuppett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to add back a check that somehow got lost in the backport/cherry-pick, but added and validated that.

Aligns with the stable34 backport (#62780): the constructor still
compared unencrypted_size against 0 instead of checking the encrypted
flag, so getSize(false) fell back to the on-disk size for zero-byte
encrypted files.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Stephen Cuppett <steve@cuppett.com>
@cuppett
cuppett force-pushed the backport/60070/stable33 branch from 551209f to f3ebb6f Compare August 4, 2026 16:56
@cuppett

cuppett commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

I missed DCO sign off, had to force repush my last commit to patch up the backport. No other changes.

@AndyScherzinger
AndyScherzinger merged commit 00ea746 into stable33 Aug 5, 2026
187 of 202 checks passed
@AndyScherzinger
AndyScherzinger deleted the backport/60070/stable33 branch August 5, 2026 08:56
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