Skip to content

Commit

Permalink
only empty top folders offer the menu entry to encrypt
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mgallien committed Aug 22, 2024
1 parent 1c3743d commit 539be0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/socketapi/socketapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ private slots:
// 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;
Expand Down

0 comments on commit 539be0a

Please sign in to comment.