From: Kevin Ottens Date: Thu, 20 Aug 2020 12:53:14 +0000 (+0200) Subject: Present sharing of E2EE files from the main dialog too X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~217^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ed5e9de9f61c7732081ab5ebd8f0d7c72967678c;p=nextcloud-desktop.git Present sharing of E2EE files from the main dialog too The visibility of the share button for the activity list is tied to the path role in the ActivityListModel, so make sure we don't return a path for E2EE files and folders. Signed-off-by: Kevin Ottens --- diff --git a/src/gui/tray/ActivityListModel.cpp b/src/gui/tray/ActivityListModel.cpp index f6c9a1778..ddfbd6fcd 100644 --- a/src/gui/tray/ActivityListModel.cpp +++ b/src/gui/tray/ActivityListModel.cpp @@ -90,21 +90,36 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const return QString(); case PathRole: if (!a._file.isEmpty()) { - auto folder = FolderMan::instance()->folder(a._folder); + auto folder = FolderMan::instance()->folderForPath(a._folder); + QString relPath(a._file); if (folder) relPath.prepend(folder->remotePath()); list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account()); - if (list.count() > 0) { - return QUrl::fromLocalFile(list.at(0)); - } + // File does not exist anymore? Let's try to open its path - if (QFileInfo(relPath).exists()) { + if (list.isEmpty() && QFileInfo(relPath).exists()) { list = FolderMan::instance()->findFileInLocalFolders(QFileInfo(relPath).path(), ast->account()); - if (list.count() > 0) { - return QVariant(list.at(0)); + } + + if (list.isEmpty()) { + return QString(); + } + + const auto path = list.at(0); + folder = FolderMan::instance()->folderForPath(path); + + // If this is an E2EE file or folder, pretend we got no path, this leads to + // hiding the share button which is what we want + if (folder) { + SyncJournalFileRecord rec; + folder->journalDb()->getFileRecord(a._file.mid(1), &rec); + if (rec.isValid() && (rec._isE2eEncrypted || !rec._e2eMangledName.isEmpty())) { + return QString(); } } + + return QUrl::fromLocalFile(path); } return QString(); case AbsolutePathRole: {