Remove token related tasks from editlocallyjob

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-05-27 22:40:11 +08:00
parent 35f988dd8b
commit 00cd258edd
No known key found for this signature in database
GPG Key ID: C839200C384636B0
3 changed files with 3 additions and 17 deletions

View File

@ -31,29 +31,24 @@ Q_LOGGING_CATEGORY(lcEditLocallyJob, "nextcloud.gui.editlocallyjob", QtInfoMsg)
EditLocallyJob::EditLocallyJob(const AccountStatePtr &accountState,
const QString &relPath,
const QString &token,
QObject *parent)
: QObject{parent}
, _accountState(accountState)
, _relPath(relPath)
, _token(token)
{
connect(this, &EditLocallyJob::callShowError, this, &EditLocallyJob::showError, Qt::QueuedConnection);
}
void EditLocallyJob::startSetup()
{
if (_token.isEmpty() || _relPath.isEmpty() || !_accountState) {
if (_relPath.isEmpty() || !_accountState) {
qCWarning(lcEditLocallyJob) << "Could not start setup."
<< "token:" << _token
<< "relPath:" << _relPath
<< "accountState:" << _accountState;
showError(tr("Could not start editing locally."), tr("An error occurred during setup."));
return;
}
// Show the loading dialog but don't show the filename until we have
// verified the token
Systray::instance()->createEditFileLocallyLoadingDialog({});
findAfolderAndConstructPaths();
}
@ -125,12 +120,6 @@ void EditLocallyJob::fetchRemoteFileParentInfo()
void EditLocallyJob::proceedWithSetup()
{
if (!_tokenVerified) {
qCWarning(lcEditLocallyJob) << "Could not proceed with setup as token is not verified.";
showError(tr("Could not validate the request to open a file from server."), tr("Please try again."));
return;
}
const auto relPathSplit = _relPath.split(QLatin1Char('/'));
if (relPathSplit.isEmpty()) {
showError(tr("Could not find a file for local editing. Make sure its path is valid and it is synced locally."), _relPath);

View File

@ -34,7 +34,6 @@ class EditLocallyJob : public QObject
public:
explicit EditLocallyJob(const AccountStatePtr &accountState,
const QString &relPath,
const QString &token,
QObject *parent = nullptr);
[[nodiscard]] static OCC::Folder *findFolderForFile(const QString &relPath, const QString &userId);
@ -86,15 +85,12 @@ private:
[[nodiscard]] bool isFileParentItemValid() const;
bool _tokenVerified = false;
bool _shouldScheduleFolderSyncAfterFileIsOpened = false;
AccountStatePtr _accountState;
QString _relPath; // full remote path for a file (as on the server)
QString _relativePathToRemoteRoot; // (relative path - Folder::remotePath()) for folders pointing to a non-root remote path e.g. '/subfolder' instead of '/'
QString _relPathParent; // a folder where the file resides ('/' if it is in the first level of a remote root, or e.g. a '/subfolder/a/b/c if it resides in a nested folder)
QString _token;
SyncFileItemPtr _fileParentItem;
QString _fileName;

View File

@ -127,7 +127,8 @@ void EditLocallyManager::editLocally(const AccountStatePtr &accountState,
if (_editLocallyJobs.contains(token)) {
return;
}
const EditLocallyJobPtr job(new EditLocallyJob(accountState, relPath, token));
const EditLocallyJobPtr job(new EditLocallyJob(accountState, relPath));
// We need to make sure the job sticks around until it is finished
_editLocallyJobs.insert(token, job);