mirror of https://github.com/nextcloud/android
Fix metadata existence check
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
49ea072e9a
commit
7140c50089
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue