Skip to content

Commit

Permalink
Do not allow sharing on version less than 2.0.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Jan 19, 2024
1 parent 9b98c34 commit 15d6d6f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/gui/filedetails/ShareView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ColumnLayout {
Layout.rightMargin: root.horizontalPadding

visible: root.userGroupSharingPossible
enabled: visible && !root.loading && !root.shareModel.isShareDisabledFolder
enabled: visible && !root.loading && !root.shareModel.isShareDisabledFolder && !shareeSearchField.isShareeFetchOngoing

accountState: root.accountState
shareItemIsFolder: root.fileDetails && root.fileDetails.isFolder
Expand Down
2 changes: 1 addition & 1 deletion src/gui/filedetails/ShareeSearchField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ TextField {
property var accountState: ({})
property bool shareItemIsFolder: false
property var shareeBlocklist: ({})
property bool isShareeFetchOngoing: shareeModel.fetchOngoing
property ShareeModel shareeModel: ShareeModel {
accountState: root.accountState
shareItemIsFolder: root.shareItemIsFolder
Expand All @@ -46,7 +47,6 @@ TextField {

placeholderText: enabled ? qsTr("Search for users or groups…") : qsTr("Sharing is not available for this folder")
placeholderTextColor: placeholderColor
enabled: !shareeModel.fetchOngoing

onActiveFocusChanged: triggerSuggestionsVisibility()
onTextChanged: triggerSuggestionsVisibility()
Expand Down
20 changes: 4 additions & 16 deletions src/gui/filedetails/sharemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,9 @@ void ShareModel::updateData()
_sharedItemType = fileRecord.isE2eEncrypted() ? SharedItemType::SharedItemTypeEncryptedFile : SharedItemType::SharedItemTypeFile;
}

if (_sharedItemType == SharedItemType::SharedItemTypeEncryptedTopLevelFolder &&
fileRecord._e2eEncryptionStatus >= SyncJournalFileRecord::EncryptionStatus::EncryptedMigratedV2_0) {
int numFoldersInPath = 0;
const auto listFoldersInPathCallback = [&numFoldersInPath](const SyncJournalFileRecord &record) {
if (record.isValid() && record.isDirectory()) {
++numFoldersInPath;
}
};
const bool listFoldersInPathSucceeded = _folder->journalDb()->listFilesInPath(fileRecord.path().toUtf8(), listFoldersInPathCallback);
const auto wasShareDisabledForFolder = _isShareDisabledFolder;
_isShareDisabledFolder = listFoldersInPathSucceeded && numFoldersInPath > 0;
if (_isShareDisabledFolder != wasShareDisabledForFolder) {
emit isShareDisabledFolderChanged();
}
}
_isShareDisabledFolder = fileRecord.isE2eEncrypted()
&& (_sharedItemType != SharedItemType::SharedItemTypeEncryptedTopLevelFolder
|| fileRecord._e2eEncryptionStatus < SyncJournalFileRecord::EncryptionStatus::EncryptedMigratedV2_0);

// Will get added when shares are fetched if no link shares are fetched
_placeholderLinkShare.reset(new Share(_accountState->account(),
Expand Down Expand Up @@ -1321,7 +1309,7 @@ bool ShareModel::serverAllowsResharing() const

bool ShareModel::isShareDisabledFolder() const

Check warning on line 1310 in src/gui/filedetails/sharemodel.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/sharemodel.cpp:1310:18 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
return false;
return _isShareDisabledFolder;
}

QVariantList ShareModel::sharees() const
Expand Down

0 comments on commit 15d6d6f

Please sign in to comment.