From bf2303cd6c8a4f4808c87370450630c917763769 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 21 Oct 2024 14:57:22 +0800 Subject: [PATCH] Ensure we are checking for tags in correct server path regardless of the particular local path Fixes issues with users who are using remote non-root sync folders Signed-off-by: Claudio Cambra --- src/gui/filedetails/filedetails.cpp | 6 +----- src/gui/filetagmodel.cpp | 12 ++++++++++-- src/gui/filetagmodel.h | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/gui/filedetails/filedetails.cpp b/src/gui/filedetails/filedetails.cpp index 2b76c70ad..9ebe8fac2 100644 --- a/src/gui/filedetails/filedetails.cpp +++ b/src/gui/filedetails/filedetails.cpp @@ -170,11 +170,7 @@ FileTagModel *FileDetails::fileTagModel() const void FileDetails::updateFileTagModel(const AccountPtr &account) { - Q_ASSERT(account); - - const auto serverRelPath = QString(folder->remotePathTrailingSlash() + name()); - - _fileTagModel = std::make_unique(serverRelPath, account); + _fileTagModel = std::make_unique(_fileRecord, _folder, account); Q_EMIT fileTagModelChanged(); } diff --git a/src/gui/filetagmodel.cpp b/src/gui/filetagmodel.cpp index 64cab4486..282ff84c1 100644 --- a/src/gui/filetagmodel.cpp +++ b/src/gui/filetagmodel.cpp @@ -20,13 +20,21 @@ Q_LOGGING_CATEGORY(lcFileTagModel, "nextcloud.gui.filetagmodel", QtInfoMsg) namespace OCC { -FileTagModel::FileTagModel(const QString &serverRelativePath, +FileTagModel::FileTagModel(const SyncJournalFileRecord &fileRecord, + const Folder * const syncFolder, const AccountPtr &account, QObject * const parent) : QAbstractListModel(parent) - , _serverRelativePath(serverRelativePath) , _account(account) { + _serverRelativePath = syncFolder->remotePathTrailingSlash() + fileRecord.path(); + + if (const auto vfsMode = syncFolder->vfs().mode(); fileRecord.isVirtualFile() && vfsMode == Vfs::WithSuffix) { + if (const auto suffix = syncFolder->vfs().fileSuffix(); !suffix.isEmpty() && _serverRelativePath.endsWith(suffix)) { + _serverRelativePath.chop(suffix.length()); + } + } + fetchFileTags(); } diff --git a/src/gui/filetagmodel.h b/src/gui/filetagmodel.h index 618702e8b..77933eccd 100644 --- a/src/gui/filetagmodel.h +++ b/src/gui/filetagmodel.h @@ -16,6 +16,8 @@ #include +#include "common/syncjournalfilerecord.h" +#include "gui/folder.h" #include "libsync/account.h" namespace OCC { @@ -31,7 +33,10 @@ class FileTagModel : public QAbstractListModel Q_PROPERTY(QString overflowTagsString READ overflowTagsString NOTIFY overflowTagsStringChanged) public: - explicit FileTagModel(const QString &serverRelativePath, const AccountPtr &account, QObject * const parent = nullptr); + explicit FileTagModel(const SyncJournalFileRecord &fileRecord, + const Folder *const syncFolder, + const AccountPtr &account, + QObject *const parent = nullptr); [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override; [[nodiscard]] QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; -- 2.30.2