Merge pull request #10388 from nextcloud/unsetEncryptedFolder

Only allow folder to unset if not in e2e subtree
This commit is contained in:
Tobias Kaminsky 2022-07-06 09:02:32 +02:00 committed by GitHub
commit d14ba71b10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -319,7 +319,7 @@ public class FileMenuFilter {
} }
private void filterUnsetEncrypted(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) { private void filterUnsetEncrypted(List<Integer> toShow, List<Integer> toHide, boolean endToEndEncryptionEnabled) {
if (files.isEmpty() || !isSingleSelection() || isSingleFile() || !isEncryptedFolder() if (files.isEmpty() || !isSingleSelection() || isSingleFile() || !isEncryptedFolder() || hasEncryptedParent()
|| !endToEndEncryptionEnabled) { || !endToEndEncryptionEnabled) {
toHide.add(R.id.action_unset_encrypted); toHide.add(R.id.action_unset_encrypted);
} else { } else {
@ -550,6 +550,13 @@ public class FileMenuFilter {
return files.iterator().next().isGroupFolder(); return files.iterator().next().isGroupFolder();
} }
private boolean hasEncryptedParent() {
OCFile folder = files.iterator().next();
OCFile parent = componentsGetter.getStorageManager().getFileById(folder.getParentId());
return parent != null && parent.isEncrypted();
}
private boolean isSingleImage() { private boolean isSingleImage() {
return isSingleSelection() && MimeTypeUtil.isImage(files.iterator().next()); return isSingleSelection() && MimeTypeUtil.isImage(files.iterator().next());
} }