Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file tag fetching for files in sync folders that have non-root remote target #7375

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions src/gui/filedetails/filedetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* for more details.
*/

#include <QDateTime>

Check failure on line 15 in src/gui/filedetails/filedetails.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/filedetails.cpp:15:10 [clang-diagnostic-error]

'QDateTime' file not found

#include "accountstate.h"
#include "filedetails.h"
Expand Down Expand Up @@ -61,25 +61,26 @@
_fileWatcher.addPath(localPath);
connect(&_fileWatcher, &QFileSystemWatcher::fileChanged, this, &FileDetails::refreshFileDetails);

const auto folder = FolderMan::instance()->folderForPath(_localPath);
if (!folder) {
_folder = FolderMan::instance()->folderForPath(_localPath);
if (!_folder) {

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

View workflow job for this annotation

GitHub Actions / build

src/gui/filedetails/filedetails.cpp:65:10 [readability-implicit-bool-conversion]

implicit conversion 'OCC::Folder *' -> bool
qCWarning(lcFileDetails) << "No folder found for path:" << _localPath << "will not load file details.";
return;
}

const auto file = _localPath.mid(folder->cleanPath().length() + 1);
const auto file = _localPath.mid(_folder->cleanPath().length() + 1);

if (!folder->journalDb()->getFileRecord(file, &_fileRecord)) {
if (!_folder->journalDb()->getFileRecord(file, &_fileRecord)) {
qCWarning(lcFileDetails) << "Invalid file record for path:"
<< _localPath
<< "will not load file details.";
}

_filelockState = _fileRecord._lockstate;
updateLockExpireString();
updateFileTagModel(folder);

_sharingAvailable = folder->accountState()->account()->capabilities().shareAPI();
const auto account = _folder->accountState()->account();
_sharingAvailable = account->capabilities().shareAPI();
updateFileTagModel(account);

Q_EMIT fileChanged();
}
Expand Down Expand Up @@ -167,16 +168,10 @@
return _fileTagModel.get();
}

void FileDetails::updateFileTagModel(const Folder * const folder)
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(folder);
const auto account = folder->accountState()->account();
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
}

bool FileDetails::sharingAvailable() const
Expand Down
3 changes: 2 additions & 1 deletion src/gui/filedetails/filedetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#pragma once

#include <QFileInfo>

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

View workflow job for this annotation

GitHub Actions / build

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

'QFileInfo' file not found
#include <QFileSystemWatcher>
#include <QLocale>
#include <QTimer>
Expand Down Expand Up @@ -66,13 +66,14 @@
private slots:
void refreshFileDetails();
void updateLockExpireString();
void updateFileTagModel(const OCC::Folder * const folder);
void updateFileTagModel(const OCC::AccountPtr &account);

private:
QString _localPath;

QFileInfo _fileInfo;
QFileSystemWatcher _fileWatcher;
Folder *_folder = nullptr;
SyncJournalFileRecord _fileRecord;
SyncJournalFileLockInfo _filelockState;
QByteArray _numericFileId;
Expand Down
12 changes: 10 additions & 2 deletions src/gui/filetagmodel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/filetagmodel.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/filetagmodel.cpp

File src/gui/filetagmodel.cpp does not conform to Custom style guidelines. (lines 23, 24)
* Copyright (C) 2023 by Claudio Cambra <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -20,13 +20,21 @@

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
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/filetagmodel.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/filetagmodel.h

File src/gui/filetagmodel.h does not conform to Custom style guidelines. (lines 36, 37, 38)
* Copyright (C) 2023 by Claudio Cambra <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -14,8 +14,10 @@

#pragma once

#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 @@
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
8 changes: 4 additions & 4 deletions src/gui/folder.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/folder.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/folder.h

File src/gui/folder.h does not conform to Custom style guidelines. (lines 226, 227, 228, 230)
* Copyright (C) by Duncan Mac-Vicar P. <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
* Copyright (C) by Klaas Freitag <[email protected]>
Expand All @@ -17,7 +17,7 @@
#ifndef MIRALL_FOLDER_H
#define MIRALL_FOLDER_H

#include "syncresult.h"

Check failure on line 20 in src/gui/folder.h

View workflow job for this annotation

GitHub Actions / build

src/gui/folder.h:20:10 [clang-diagnostic-error]

'syncresult.h' file not found
#include "progressdispatcher.h"
#include "common/syncjournaldb.h"
#include "networkjobs.h"
Expand Down Expand Up @@ -223,11 +223,11 @@
void setIgnoreHiddenFiles(bool ignore);

// Used by the Socket API
SyncJournalDb *journalDb() { return &_journal; }
SyncEngine &syncEngine() { return *_engine; }
Vfs &vfs() { return *_vfs; }
SyncJournalDb *journalDb() const { return &_journal; }
SyncEngine &syncEngine() const { return *_engine; }
Vfs &vfs() const { return *_vfs; }

RequestEtagJob *etagJob() { return _requestEtagJob; }
RequestEtagJob *etagJob() const { return _requestEtagJob; }
std::chrono::milliseconds msecSinceLastSync() const { return std::chrono::milliseconds(_timeSinceLastSyncDone.elapsed()); }
std::chrono::milliseconds msecLastSyncDuration() const { return _lastSyncDuration; }
int consecutiveFollowUpSyncs() const { return _consecutiveFollowUpSyncs; }
Expand Down
Loading