Skip to content

fix(e2ee): sub folder creation#17266

Open
alperozturk96 wants to merge 1 commit into
masterfrom
fix/e2ee-sub-encrypted-folder-creation
Open

fix(e2ee): sub folder creation#17266
alperozturk96 wants to merge 1 commit into
masterfrom
fix/e2ee-sub-encrypted-folder-creation

Conversation

@alperozturk96

@alperozturk96 alperozturk96 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Issue

Cannot create encrypted sub folder of sub folder

RemoteOperationResult:
 processed: UNHANDLED_HTTP_CODE
 HTTP Status: 412 Precondition Failed

2026-07-01 12:25:30.215
E/OperationsService: Unexpected error for <user>@<server>

java.lang.RuntimeException: Could not clean up after failing folder creation!
   at [com.owncloud.android](http://com.owncloud.android/).operations.CreateFolderOperation.encryptedCreateV2([CreateFolderOperation.java:385](http://createfolderoperation.java:385/))
   at [com.owncloud.android.operations.CreateFolderOperation.run](http://com.owncloud.android.operations.createfolderoperation.run/)([CreateFolderOperation.java:112](http://createfolderoperation.java:112/))
   at [com.owncloud.android](http://com.owncloud.android/).lib.common.operations.RemoteOperation.execute([RemoteOperation.java:193](http://remoteoperation.java:193/))
   at [com.owncloud.android.services](http://com.owncloud.android.services/).OperationsService$ServiceHandler.nextOperation([OperationsService.java:444](http://operationsservice.java:444/))
   at [com.owncloud.android.services](http://com.owncloud.android.services/).OperationsService$ServiceHandler.handleMessage([OperationsService.java:407](http://operationsservice.java:407/))
   at android.os.Handler.dispatchMessage([Handler.java:110](http://handler.java:110/))
   at android.os.Looper.loopOnce([Looper.java:248](http://looper.java:248/))
   at android.os.Looper.loop([Looper.java:338](http://looper.java:338/))
   at [android.os.HandlerThread.run](http://android.os.handlerthread.run/)([HandlerThread.java:85](http://handlerthread.java:85/))

Caused by: [com.owncloud.android](http://com.owncloud.android/).operations.UploadException: Could not lock folder
   at [com.owncloud.android](http://com.owncloud.android/).utils.EncryptionUtils.lockFolder([EncryptionUtils.java:1179](http://encryptionutils.java:1179/))
   at [com.owncloud.android](http://com.owncloud.android/).operations.CreateFolderOperation.encryptedCreateV2([CreateFolderOperation.java:283](http://createfolderoperation.java:283/))
   ... 8 more

Signed-off-by: alperozturk96 <alper_ozturk@proton.me>
private const val INCREMENTER = 1L

@Suppress("ReturnCount")
fun getCounter(context: Context, parentFile: OCFile, metadata: Any?): Long {

@alperozturk96 alperozturk96 Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since same logic needs to be used in CreateFolderOperation.java better to consolidate.

/**
* Returns true if the given E2EE version is v2 or newer.
*/
fun isV2Plus(context: Context): Boolean {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Another helper function directly getting from context.


if (result.isSuccess()) {
updateMetadataForE2E(object, e2eData, clientData, e2eFiles, arbitraryDataProvider, encryptionUtilsV2, metadataExists);
updateMetadataForE2E(object, e2eData, clientData, e2eFiles, arbitraryDataProvider, encryptionUtilsV2, isV1MetadataExists);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

metadataExists is wrong variable name. This is only used for V1.

if (metadataExists) {
if (isV1MetadataExists) {
// update metadata
if (E2EVersionHelper.INSTANCE.isV2Plus(version)) {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since isV1MetadataExists only needed for v1 why do we have v2 function in it? @tobiasKaminsky This is for separate PR.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

APK file: https://github.com/nextcloud/android/actions/runs/28514025082/artifacts/8008586973
To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.
qrcode (please click on link to get QR code displayed)

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

blue-Light-Screenshot test failed, but no output was generated. Maybe a preliminary stage failed.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

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.

1 participant