|
@@ -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,14 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
// mContext);
|
|
|
|
|
|
Object object = EncryptionUtils.downloadFolderMetadata(parentFile, client, mContext, user);
|
|
|
+ if (object instanceof DecryptedFolderMetadataFileV1 decrypted && decrypted.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
|
|
@@ -507,8 +509,11 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
String encryptedMetadataKey = EncryptionUtils.encryptStringAsymmetric(metadataKey, publicKey);
|
|
|
metadata.getMetadata().setMetadataKey(encryptedMetadataKey);
|
|
|
|
|
|
+ if (object instanceof DecryptedFolderMetadataFileV1) {
|
|
|
+ metadata = (DecryptedFolderMetadataFileV1) object;
|
|
|
+ }
|
|
|
+
|
|
|
object = metadata;
|
|
|
- metadataExists = false;
|
|
|
}
|
|
|
|
|
|
// todo fail if no metadata
|
|
@@ -669,7 +674,6 @@ public class UploadFileOperation extends SyncOperation {
|
|
|
data.setFilename(mFile.getDecryptedFileName());
|
|
|
data.setMimetype(mFile.getMimeType());
|
|
|
data.setKey(EncryptionUtils.encodeBytesToBase64String(key));
|
|
|
-
|
|
|
decryptedFile.setEncrypted(data);
|
|
|
decryptedFile.setInitializationVector(EncryptionUtils.encodeBytesToBase64String(iv));
|
|
|
decryptedFile.setAuthenticationTag(encryptedFile.getAuthenticationTag());
|