Skip to content

fix(encryption): Refactor EncryptionWrapper with HomeMountPoint support#60001

Open
cuppett wants to merge 1 commit intonextcloud:masterfrom
cuppett:refactor/encryption-wrapper-homemount-support
Open

fix(encryption): Refactor EncryptionWrapper with HomeMountPoint support#60001
cuppett wants to merge 1 commit intonextcloud:masterfrom
cuppett:refactor/encryption-wrapper-homemount-support

Conversation

@cuppett
Copy link
Copy Markdown
Contributor

@cuppett cuppett commented Apr 29, 2026

Summary

Rewrite conditional flow to use early-return guards: skip IDisableEncryptionStorage, skip the root mount, respect encryptHomeStorage for HomeMountPoints. Uses IAppConfig for the encryptHomeStorage setting with a legacy string fallback for the upgrade window.

Spawned from #57279

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Rewrite conditional flow to use early-return guards: skip IDisableEncryptionStorage,
skip the root mount, respect encryptHomeStorage for HomeMountPoints. Uses IAppConfig
for the encryptHomeStorage setting with a legacy string fallback for the upgrade window.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Stephen Cuppett <steve@cuppett.com>
@cuppett cuppett requested a review from a team as a code owner April 29, 2026 23:49
@cuppett cuppett requested review from Altahrim, ArtificialOwl, leftybournes and salmart-dev and removed request for a team April 29, 2026 23:49
@cuppett cuppett added this to the Nextcloud 34 milestone Apr 29, 2026
@cuppett cuppett added 3. to review Waiting for reviews feature: encryption (client-side) ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring) labels Apr 29, 2026
Copy link
Copy Markdown
Contributor Author

@cuppett cuppett left a comment

Choose a reason for hiding this comment

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

Unclear if I need to keep this in here after #60002.

Comment on lines +123 to +125
private function parseLegacyBoolString(string $value): bool {
return in_array(strtolower(trim($value)), ['1', 'true', 'yes', 'on'], true);
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this should be refactored out as well after #60002.

}

private function shouldEncryptHomeStorage(): bool {
$appConfig = Server::get(IAppConfig::class);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can't we use dependency injection in the constructor?

Comment on lines +111 to 116
} catch (AppConfigTypeConflictException) {
// Stored as VALUE_STRING from a pre-upgrade installation.
// RetypeEncryptionConfigKeys repair step will fix the type on occ upgrade.
return $this->parseLegacyBoolString(
$appConfig->getValueString('encryption', 'encryptHomeStorage', '1')
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not needed I think.

return $storage;
} catch (\Throwable) {
// DB not ready (e.g. oc_appconfig does not yet exist during install).
return true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When can this happen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This likely goes away if we can use the constructor injection you asked about. This Throwable is triggered if $appConfig is null from the fetch above. I'll make those two adjustments and trigger the tests locally.

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 feature: encryption (server-side) ♻️ refactor Refactor code (not a bug fix, not a feature just refactoring)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants