Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
  • Loading branch information
mgallien committed Jun 25, 2021
1 parent 9f168ba commit 10f463f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
32 changes: 19 additions & 13 deletions src/common/vfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ Result<bool, QString> Vfs::checkAvailability(const QString &path)
}
}
#else
Q_UNUSED(path);
Q_UNUSED(mode)
Q_UNUSED(path)
#endif
return true;
}
Expand Down Expand Up @@ -149,26 +150,29 @@ Q_LOGGING_CATEGORY(lcPlugin, "plugins", QtInfoMsg)
bool OCC::isVfsPluginAvailable(Vfs::Mode mode)
{
// TODO: cache plugins available?
if (mode == Vfs::Off)
if (mode == Vfs::Off) {
return true;
}

auto name = modeToPluginName(mode);
if (name.isEmpty())
if (name.isEmpty()) {
return false;
auto pluginPath = pluginFileName(QStringLiteral("vfs"), name);
QPluginLoader loader(pluginPath);
}

QPluginLoader loader(pluginFileName(QStringLiteral("vfs"), name));

auto basemeta = loader.metaData();
if (basemeta.isEmpty() || !basemeta.contains(QStringLiteral("IID"))) {
const auto baseMetaData = loader.metaData();
if (baseMetaData.isEmpty() || !baseMetaData.contains(QStringLiteral("IID"))) {
qCDebug(lcPlugin) << "Plugin doesn't exist" << loader.fileName();
return false;
}
if (basemeta[QStringLiteral("IID")].toString() != QLatin1String("org.owncloud.PluginFactory")) {
qCWarning(lcPlugin) << "Plugin has wrong IID" << loader.fileName() << basemeta[QStringLiteral("IID")];
if (baseMetaData[QStringLiteral("IID")].toString() != QStringLiteral("org.owncloud.PluginFactory")) {
qCWarning(lcPlugin) << "Plugin has wrong IID" << loader.fileName() << baseMetaData[QStringLiteral("IID")];
return false;
}

auto metadata = basemeta[QStringLiteral("MetaData")].toObject();
if (metadata[QStringLiteral("type")].toString() != QLatin1String("vfs")) {
const auto metadata = baseMetaData[QStringLiteral("MetaData")].toObject();
if (metadata[QStringLiteral("type")].toString() != QStringLiteral("vfs")) {
qCWarning(lcPlugin) << "Plugin has wrong type" << loader.fileName() << metadata[QStringLiteral("type")];
return false;
}
Expand Down Expand Up @@ -226,9 +230,11 @@ std::unique_ptr<Vfs> OCC::createVfsFromPlugin(Vfs::Mode mode)
return std::unique_ptr<Vfs>(new VfsOff);

auto name = modeToPluginName(mode);
if (name.isEmpty())
if (name.isEmpty()) {
return nullptr;
auto pluginPath = pluginFileName(QStringLiteral("vfs"), name);
}

const auto pluginPath = pluginFileName(QStringLiteral("vfs"), name);

if (!isVfsPluginAvailable(mode)) {
qCCritical(lcPlugin) << "Could not load plugin: not existant or bad metadata" << pluginPath;
Expand Down
14 changes: 1 addition & 13 deletions src/libsync/vfs/cfapi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@ if (WIN32)

target_include_directories("${synclib_NAME}_vfs_cfapi" BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR} INTERFACE ${CMAKE_BINARY_DIR})

if(APPLE)
# for being loadable when client run from build dir
set(vfs_buildoutputdir "${BIN_OUTPUT_DIRECTORY}/${OWNCLOUD_OSX_BUNDLE}/Contents/PlugIns/")
set_target_properties("${synclib_NAME}_vfs_cfapi"
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
RUNTIME_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
)
# For being lodable when client run from install dir (after make macdeployqt)
set(vfs_installdir "${LIB_INSTALL_DIR}/../PlugIns")
else()
set(vfs_installdir "${PLUGINDIR}")
endif()
set(vfs_installdir "${PLUGINDIR}")

GENERATE_EXPORT_HEADER( "${synclib_NAME}_vfs_cfapi"
BASE_NAME "${synclib_NAME}_vfs_cfapi"
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/vfs/cfapi/vfs_cfapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Result<void, QString> VfsCfApi::updateMetadata(const QString &filePath, time_t m
return cfapi::updatePlaceholderInfo(handle, modtime, size, fileId);
} else {
qCWarning(lcCfApi) << "Couldn't update metadata for non existing file" << localPath;
return {"Couldn't update metadata"};
return { "Couldn't update metadata" };
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsync/vfs/suffix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(APPLE)
LIBRARY_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
RUNTIME_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
)
# For being lodable when client run from install dir (after make macdeployqt)
# For being loadable when client run from install dir (after make macdeployqt)
set(vfs_installdir "${LIB_INSTALL_DIR}/../PlugIns")
else()
set(vfs_installdir "${PLUGINDIR}")
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/vfs/xattr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (UNIX)
LIBRARY_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
RUNTIME_OUTPUT_DIRECTORY ${vfs_buildoutputdir}
)
# For being lodable when client run from install dir (after make macdeployqt)
# For being loadable when client run from install dir (after make macdeployqt)
set(vfs_installdir "${LIB_INSTALL_DIR}/../PlugIns")
else()
set(vfs_installdir "${PLUGINDIR}")
Expand Down

0 comments on commit 10f463f

Please sign in to comment.