Fix metadata existence check

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-03-12 10:03:52 +01:00 committed by Alper Öztürk
parent 49ea072e9a
commit 7140c50089
1 changed files with 8 additions and 4 deletions

View File

@ -441,6 +441,7 @@ public class UploadFileOperation extends SyncOperation {
}
}
// TODO REFACTOR
@SuppressLint("AndroidLintUseSparseArrays") // gson cannot handle sparse arrays easily, therefore use hashmap
private RemoteOperationResult encryptedUpload(OwnCloudClient client, OCFile parentFile) {
RemoteOperationResult result = null;
@ -489,13 +490,18 @@ public class UploadFileOperation extends SyncOperation {
// mContext);
Object object = EncryptionUtils.downloadFolderMetadata(parentFile, client, mContext, user);
if (object != null) {
if (object instanceof DecryptedFolderMetadataFileV1) {
if (((DecryptedFolderMetadataFileV1) object).getMetadata() != null) {
metadataExists = true;
}
}
}
if (CapabilityUtils.getCapability(mContext).getEndToEndEncryptionApiVersion().compareTo(E2EVersion.V2_0) >= 0) {
if (object == null) {
// TODO return error
return new RemoteOperationResult(new IllegalStateException("Metadata does not exist"));
} else {
metadataExists = true;
}
} else {
// v1 is allowed to be null, thus create it
@ -512,7 +518,6 @@ public class UploadFileOperation extends SyncOperation {
}
object = metadata;
metadataExists = true;
}
// todo fail if no metadata
@ -696,7 +701,6 @@ public class UploadFileOperation extends SyncOperation {
serializedFolderMetadata = EncryptionUtils.serializeJSON(encryptedFolderMetadata);
}
// FIXME after first failed upload folder stay locked, uploadMetadata throws UploadException for encrypted folder
// upload metadata
EncryptionUtils.uploadMetadata(parentFile,
serializedFolderMetadata,