mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Merge pull request #1962 from nextcloud/topOfEncryption
Detect top of encryption folders
This commit is contained in:
commit
375d66761a
3 changed files with 16 additions and 4 deletions
|
@ -371,7 +371,7 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|||
|
||||
// if local folder is encrypted, download fresh metadata
|
||||
DecryptedFolderMetadata metadata;
|
||||
boolean encryptedAncestor = FileStorageUtils.checkIfInEncryptedFolder(mLocalFolder, mStorageManager);
|
||||
boolean encryptedAncestor = FileStorageUtils.checkEncryptionStatus(mLocalFolder, mStorageManager);
|
||||
if (encryptedAncestor && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
|
||||
metadata = EncryptionUtils.downloadFolderMetadata(mLocalFolder, getClient(), mContext, mAccount);
|
||||
} else {
|
||||
|
@ -470,7 +470,8 @@ public class RefreshFolderOperation extends RemoteOperation {
|
|||
}
|
||||
}
|
||||
|
||||
updatedFile.setEncrypted(encryptedAncestor);
|
||||
boolean encrypted = FileStorageUtils.checkEncryptionStatus(updatedFile, mStorageManager);
|
||||
updatedFile.setEncrypted(encrypted);
|
||||
|
||||
updatedFiles.add(updatedFile);
|
||||
}
|
||||
|
|
|
@ -381,7 +381,7 @@ public class UploadFileOperation extends SyncOperation {
|
|||
mFile.setParentId(parent.getFileId());
|
||||
|
||||
// check if any parent is encrypted
|
||||
encryptedAncestor = FileStorageUtils.checkIfInEncryptedFolder(parent, getStorageManager());
|
||||
encryptedAncestor = FileStorageUtils.checkEncryptionStatus(parent, getStorageManager());
|
||||
mFile.setEncrypted(encryptedAncestor);
|
||||
|
||||
// try to unlock folder with stored token, e.g. when upload needs to be resumed or app crashed
|
||||
|
|
|
@ -383,7 +383,18 @@ public class FileStorageUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean checkIfInEncryptedFolder(OCFile file, FileDataStorageManager storageManager) {
|
||||
/**
|
||||
* Checks and returns true if file itself or ancestor is encrypted
|
||||
*
|
||||
* @param file file to check
|
||||
* @param storageManager up to date reference to storage manager
|
||||
* @return true if file itself or ancestor is encrypted
|
||||
*/
|
||||
public static boolean checkEncryptionStatus(OCFile file, FileDataStorageManager storageManager) {
|
||||
if (file.isEncrypted()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
while (!OCFile.ROOT_PATH.equals(file.getRemotePath())) {
|
||||
if (file.isEncrypted()) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue