only empty top folders offer the menu entry to encrypt

in the contextual menu shown in files explorer will show encrypt menu
entry only for top folders that are non-encrypted and empty

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2024-08-21 17:41:35 +02:00 committed by Matthieu Gallien
parent 1c3743d670
commit 539be0a16a
2 changed files with 13 additions and 1 deletions

View File

@ -1242,7 +1242,8 @@ void SocketApi::sendEncryptFolderCommandMenuEntries(const QFileInfo &fileInfo,
!fileData.folder->accountState()->account() ||
!fileData.folder->accountState()->account()->capabilities().clientSideEncryptionAvailable() ||
!FileSystem::isDir(fileInfo.absoluteFilePath()) ||
isE2eEncryptedPath) {
isE2eEncryptedPath ||
!fileData.isFolderEmpty()) {
return;
}
@ -1328,6 +1329,15 @@ QString SocketApi::FileData::folderRelativePathNoVfsSuffix() const
return result;
}
bool SocketApi::FileData::isFolderEmpty() const
{
if (FileSystem::isDir(localPath)) {
const auto nativeFolder = QDir{localPath};
return nativeFolder.isEmpty();
}
return false;
}
SyncFileStatus SocketApi::FileData::syncFileStatus() const
{
if (!folder)

View File

@ -98,6 +98,8 @@ private:
// Relative path of the file locally, without any vfs suffix
[[nodiscard]] QString folderRelativePathNoVfsSuffix() const;
[[nodiscard]] bool isFolderEmpty() const;
Folder *folder = nullptr;
// Absolute path of the file locally. (May be a virtual file)
QString localPath;