Skip to content

Commit 03d782f

Browse files
committed
Auto mount and unmount openvfs
1 parent 711741c commit 03d782f

File tree

19 files changed

+249
-91
lines changed

19 files changed

+249
-91
lines changed

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ include(FeatureSummary)
99
find_package(ECM 6.0.0 REQUIRED NO_MODULE)
1010

1111
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")
12-
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)
1312

1413
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
1514

@@ -148,12 +147,12 @@ if(BUILD_TESTING)
148147
add_subdirectory(test)
149148
endif()
150149

151-
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
152-
153150
if(ECM_VERSION VERSION_GREATER_EQUAL 5.79)
154151
message(STATUS "Suitable ECM ${ECM_VERSION} found, installing clang-format git hook")
155152
include(KDEGitCommitHooks)
156153
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
157154
else()
158155
message(WARNING "ECM ${ECM_VERSION} too old, cannot install clang-format git hook")
159156
endif()
157+
158+
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES INCLUDE_QUIET_PACKAGES)

src/gui/folder.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ Folder::Folder(const FolderDefinition &definition, const AccountStatePtr &accoun
124124
}
125125
});
126126

127-
// Potentially upgrade suffix vfs to windows vfs
128-
OC_ENFORCE(_vfs);
129127
// Initialize the vfs plugin. Do this after the UI is running, so we can show a dialog when something goes wrong.
130128
QTimer::singleShot(0, this, &Folder::startVfs);
131129
}
@@ -186,7 +184,12 @@ bool Folder::checkLocalPath()
186184
error = pathLengthCheck.error();
187185
}
188186

189-
if (error.isEmpty()) {
187+
// Potentially upgrade suffix vfs to windows vfs
188+
OC_ENFORCE(_vfs);
189+
const auto result = VfsPluginManager::instance().checkAvailability(path(), _vfs->mode());
190+
if (!result) {
191+
error = result.error();
192+
} else if (error.isEmpty()) {
190193
qCDebug(lcFolder) << u"Checked local path ok";
191194
if (!_journal.open()) {
192195
error = tr("Failed to open the database for »%1«.").arg(_definition.localPath());
@@ -518,13 +521,6 @@ void Folder::startVfs()
518521
OC_ENFORCE(_vfs);
519522
OC_ENFORCE(_vfs->mode() == _definition.virtualFilesMode);
520523

521-
const auto result = Vfs::checkAvailability(path(), _vfs->mode());
522-
if (!result) {
523-
_syncResult.appendErrorString(result.error());
524-
setSyncState(SyncResult::SetupError);
525-
return;
526-
}
527-
528524
VfsSetupParams vfsParams(_accountState->account(), webDavUrl(), _definition.spaceId(), displayName(), _engine.get());
529525
vfsParams.filesystemPath = path();
530526
vfsParams.journal = &_journal;

src/gui/folderdefinition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ FolderDefinition FolderDefinition::load(QSettings &settings)
106106
QString vfsModeString = settings.value("virtualFilesMode").toString();
107107

108108
const auto vfs = Utility::isWindows() ? Vfs::Mode::WindowsCfApi : Vfs::Mode::XAttr;
109-
if (auto result = Vfs::checkAvailability(folder.localPath(), vfs); result) {
109+
if (auto result = VfsPluginManager::instance().checkAvailability(folder.localPath(), vfs); result) {
110110
vfsModeString = Utility::enumToString(vfs);
111111
} else {
112112
qCWarning(lcFolder) << u"Failed to upgrade" << folder.localPath() << u"to" << vfs << result.error();

src/gui/folderman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ void FolderMan::slotReloadSyncOptions()
766766

767767
bool FolderMan::checkVfsAvailability(const QString &path, Vfs::Mode mode) const
768768
{
769-
return unsupportedConfiguration(path) && Vfs::checkAvailability(path, mode);
769+
return unsupportedConfiguration(path) && VfsPluginManager::instance().checkAvailability(path, mode);
770770
}
771771

772772
Folder *FolderMan::addFolderFromWizard(const AccountStatePtr &accountStatePtr, FolderDefinition &&folderDefinition, bool useVfs)

src/gui/folderwizard/folderwizardlocalpath.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool FolderWizardLocalPath::isComplete() const
6464
auto accountUuid = folderWizardPrivate()->accountState()->account()->uuid();
6565
QString errorStr = FolderMan::instance()->checkPathValidityForNewFolder(localPath(), FolderMan::NewFolderType::SpacesSyncRoot, accountUuid);
6666
if (errorStr.isEmpty()) {
67-
if (auto result = Vfs::checkAvailability(localPath(), VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
67+
if (auto result = VfsPluginManager::instance().checkAvailability(localPath(), VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
6868
errorStr = result.error();
6969
}
7070
}

src/gui/newwizard/pages/accountconfiguredwizardpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AccountConfiguredWizardPage::AccountConfiguredWizardPage(const QString &defaultS
3838
// the directory chooser should guarantee that the directory exists
3939
Q_ASSERT(QDir(directory).exists());
4040

41-
if (auto result = Vfs::checkAvailability(directory, VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
41+
if (auto result = VfsPluginManager::instance().checkAvailability(directory, VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
4242
auto *box =
4343
new FontIconMessageBox({Resources::FontIcon::DefaultGlyphes::Warning}, tr("Sync location not supported"), result.error(), QMessageBox::Ok, this);
4444
box->setAttribute(Qt::WA_DeleteOnClose);

src/gui/newwizard/states/accountconfiguredsetupwizardstate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void AccountConfiguredSetupWizardState::evaluatePage()
5858
return;
5959
}
6060

61-
if (auto result = Vfs::checkAvailability(syncTargetDir, VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
61+
if (auto result = VfsPluginManager::instance().checkAvailability(syncTargetDir, VfsPluginManager::instance().bestAvailableVfsMode()); !result) {
6262
emitEvaluationFailedError(result.error());
6363
return;
6464
}

src/libsync/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
find_package(LibreGraphAPI 1.0.4 REQUIRED)
22
set_package_properties(LibreGraphAPI PROPERTIES
33
URL https://github.com/owncloud/libre-graph-api-cpp-qt-client.git
4-
DESCRIPTION "Libre Graph is a free API for cloud collaboration inspired by the MS Graph API."
5-
TYPE OPTIONAL
4+
DESCRIPTION "Libre Graph is a free API for cloud collaboration inspired by the MS Graph API"
5+
TYPE REQUIRED
66
)
77

88
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

src/libsync/common/plugin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
#pragma once
2020

21+
#include "libsync/common/result.h"
2122
#include "libsync/opencloudsynclib.h"
23+
2224
#include <QObject>
2325

2426
namespace OCC {
@@ -28,6 +30,7 @@ class OPENCLOUD_SYNC_EXPORT PluginFactory
2830
public:
2931
virtual ~PluginFactory();
3032
virtual QObject *create(QObject *parent) = 0;
33+
virtual Result<void, QString> checkAvailability(const QString &path) const = 0;
3134
};
3235

3336
template <class PluginClass>

src/libsync/logger.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ void Logger::open(const QString &name)
160160
}
161161

162162
if (!openSucceeded) {
163-
std::cerr << "Failed to open the log file" << std::endl;
163+
std::cerr << "Failed to open the log file: '" << qPrintable(_logFile.fileName()) << "' Error: '" << qPrintable(_logFile.errorString()) << "'"
164+
<< std::endl;
164165
return;
165166
}
166167
_logstream.reset(new QTextStream(&_logFile));

0 commit comments

Comments
 (0)