Skip to content

Commit

Permalink
Show more informative error message when VFS hydration fails. Display…
Browse files Browse the repository at this point in the history
… a popup and put an error into activity list. More detailed logs.

Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Oct 19, 2023
1 parent bac61c7 commit a6dfac1
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/common/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ public slots:
void beginHydrating();
/// Emitted when the hydration ends
void doneHydrating();
// Emitted when hydration fails
void failureHydrating(int errorCode, int statusCode, const QString &errorString, const QString &fileName);

protected:
/** Setup the plugin for the folder.
Expand Down
3 changes: 3 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(client_UI_SRCS
passwordinputdialog.ui
proxyauthdialog.ui
mnemonicdialog.ui
vfsdownloaderrordialog.ui
wizard/flow2authwidget.ui
wizard/owncloudadvancedsetuppage.ui
wizard/owncloudconnectionmethoddialog.ui
Expand Down Expand Up @@ -158,6 +159,8 @@ set(client_SRCS
thumbnailjob.cpp
userinfo.h
userinfo.cpp
vfsdownloaderrordialog.h
vfsdownloaderrordialog.cpp
accountstate.h
accountstate.cpp
addcertificatedialog.h
Expand Down
42 changes: 42 additions & 0 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "common/vfs.h"
#include "creds/abstractcredentials.h"
#include "settingsdialog.h"
#include "vfsdownloaderrordialog.h"

#include <QTimer>
#include <QUrl>
Expand All @@ -46,6 +47,8 @@
#include <QMessageBox>
#include <QPushButton>
#include <QApplication>
#include <QLabel>
#include <QLayout>

namespace {
#ifndef VERSION_C
Expand Down Expand Up @@ -506,6 +509,7 @@ void Folder::startVfs()

connect(_vfs.data(), &Vfs::beginHydrating, this, &Folder::slotHydrationStarts);
connect(_vfs.data(), &Vfs::doneHydrating, this, &Folder::slotHydrationDone);
connect(_vfs.data(), &Vfs::failureHydrating, this, &Folder::slotHydrationFailed);

connect(&_engine->syncFileStatusTracker(), &SyncFileStatusTracker::fileStatusChanged,
_vfs.data(), &Vfs::fileStatusChanged);
Expand Down Expand Up @@ -1510,6 +1514,44 @@ void Folder::slotHydrationDone()
emit syncStateChange();
}

void Folder::slotHydrationFailed(int errorCode, int statusCode, const QString &errorString, const QString &fileName)
{
_syncResult.setStatus(SyncResult::Error);
const auto errorMessageDetails = tr("Virtual file download failed with code \"%1\", status \"%2\" and error message \"%3\"")
.arg(errorCode)
.arg(statusCode)
.arg(errorString);

const auto errorMessageBox = new VfsDownloadErrorDialog(fileName, errorMessageDetails);

errorMessageBox->setAttribute(Qt::WA_DeleteOnClose);
errorMessageBox->setWindowTitle(Theme::instance()->appNameGUI());
errorMessageBox->setMinimumWidth(150);
errorMessageBox->setMinimumHeight(100);

// add label and hide it
const auto errorMessageDetailsLabel = new QLabel(errorMessageDetails);
errorMessageDetailsLabel->setWordWrap(true);
errorMessageBox->layout()->addWidget(errorMessageDetailsLabel);
errorMessageDetailsLabel->hide();

auto buttonsLayout = new QHBoxLayout;

// add button for showing label on click
const auto acceptButton = new QPushButton(tr("OK"));
const auto showErrorMessageDetailsButton = new QPushButton(tr("> More details"));

buttonsLayout->addWidget(showErrorMessageDetailsButton);
buttonsLayout->addWidget(acceptButton);
connect(showErrorMessageDetailsButton, &QPushButton::clicked, errorMessageDetailsLabel, &QPushButton::show);

errorMessageBox->layout()->addItem(buttonsLayout);

errorMessageBox->show();
errorMessageBox->activateWindow();
errorMessageBox->raise();
}

void Folder::slotCapabilitiesChanged()
{
if (_accountState->account()->capabilities().filesLockAvailable()) {
Expand Down
3 changes: 3 additions & 0 deletions src/gui/folder.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ private slots:
/** Unblocks normal sync operation */
void slotHydrationDone();

/* Hydration failed, perform required steps to notify user */
void slotHydrationFailed(int errorCode, int statusCode, const QString &errorString, const QString &fileName);

void slotCapabilitiesChanged();

private:
Expand Down
4 changes: 2 additions & 2 deletions src/gui/passwordinputdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>276</width>
<height>125</height>
<width>291</width>
<height>201</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down
34 changes: 34 additions & 0 deletions src/gui/vfsdownloaderrordialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*

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

View workflow job for this annotation

GitHub Actions / build

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

File src/gui/vfsdownloaderrordialog.cpp (lines 18, 22): Code does not conform to Custom style guidelines.
* Copyright (C) by Felix Weilbach <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#include "vfsdownloaderrordialog.h"
#include "ui_vfsdownloaderrordialog.h"

namespace OCC {

VfsDownloadErrorDialog::VfsDownloadErrorDialog(const QString &fileName, const QString &errorMessage, QWidget *parent)
: QDialog(parent)
, _ui(new Ui::VfsDownloadErrorDialog) {
_ui->setupUi(this);

_ui->descriptionLabel->setText(tr("Error downloading %1").arg(fileName));
_ui->explanationLabel->setText(tr("%1 could not be downloaded.").arg(fileName));
_ui->moreDetailsLabel->setText(errorMessage);
_ui->moreDetailsLabel->setVisible(false);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
}

VfsDownloadErrorDialog::~VfsDownloadErrorDialog() = default;
}
44 changes: 44 additions & 0 deletions src/gui/vfsdownloaderrordialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*

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

View workflow job for this annotation

GitHub Actions / build

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

File src/gui/vfsdownloaderrordialog.h (lines 17, 24, 28): Code does not conform to Custom style guidelines.
* Copyright (C) by Felix Weilbach <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#pragma once

#include <accountfwd.h>
#include <account.h>

#include <memory>

#include <QDialog>

namespace OCC {

class Folder;

namespace Ui {
class VfsDownloadErrorDialog;
}

class VfsDownloadErrorDialog : public QDialog
{
Q_OBJECT

public:
explicit VfsDownloadErrorDialog(const QString &fileName, const QString &errorMessage, QWidget *parent = nullptr);

~VfsDownloadErrorDialog() override;

private:
std::unique_ptr<Ui::VfsDownloadErrorDialog> _ui;
};
}
166 changes: 166 additions & 0 deletions src/gui/vfsdownloaderrordialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OCC::VfsDownloadErrorDialog</class>
<widget class="QDialog" name="OCC::VfsDownloadErrorDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>397</width>
<height>155</height>
</rect>
</property>
<property name="windowTitle">
<string>Download error</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Error downloading</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="explanationLabel">
<property name="text">
<string>could not be downloaded</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moreDetailsButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&gt; More details</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="moreDetailsLabel">
<property name="text">
<string>More details</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="200">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="200">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="115">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>moreDetailsButton</sender>
<signal>clicked()</signal>
<receiver>moreDetailsLabel</receiver>
<slot>show()</slot>
<hints>
<hint type="sourcelabel">
<x>47</x>
<y>112</y>
</hint>
<hint type="destinationlabel">
<x>198</x>
<y>141</y>
</hint>
</hints>
</connection>
<connection>
<sender>moreDetailsButton</sender>
<signal>clicked()</signal>
<receiver>moreDetailsButton</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel">
<x>47</x>
<y>63</y>
</hint>
<hint type="destinationlabel">
<x>47</x>
<y>63</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Loading

0 comments on commit a6dfac1

Please sign in to comment.