Skip to content

Commit

Permalink
Ensure we are checking for tags in correct server path regardless of …
Browse files Browse the repository at this point in the history
…the particular local path

Fixes issues with users who are using remote non-root sync folders

Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Oct 21, 2024
1 parent 6574625 commit 9c5d1e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/gui/filedetails/filedetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,7 @@ FileTagModel *FileDetails::fileTagModel() const

void FileDetails::updateFileTagModel(const AccountPtr &account)

Check warning on line 171 in src/gui/filedetails/filedetails.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/filedetails.cpp:171:19 [readability-convert-member-functions-to-static]

method 'updateFileTagModel' can be made static
{
Q_ASSERT(account);

const auto serverRelPath = QString(folder->remotePathTrailingSlash() + name());

_fileTagModel = std::make_unique<FileTagModel>(serverRelPath, account);
_fileTagModel = std::make_unique<FileTagModel>(_fileRecord, _folder, account);
Q_EMIT fileTagModelChanged();

Check warning on line 174 in src/gui/filedetails/filedetails.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/filedetails.cpp:174:12 [modernize-use-trailing-return-type]

use a trailing return type for this function
}

Expand Down
12 changes: 10 additions & 2 deletions src/gui/filetagmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
7 changes: 6 additions & 1 deletion src/gui/filetagmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <QAbstractListModel>

Check failure on line 17 in src/gui/filetagmodel.h

View workflow job for this annotation

GitHub Actions / build

src/gui/filetagmodel.h:17:10 [clang-diagnostic-error]

'QAbstractListModel' file not found

#include "common/syncjournalfilerecord.h"
#include "gui/folder.h"
#include "libsync/account.h"

namespace OCC {
Expand All @@ -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;
Expand Down

0 comments on commit 9c5d1e2

Please sign in to comment.