From 2092df58067898370ea5528acb52ec93a69e3547 Mon Sep 17 00:00:00 2001 From: Camila Ayres Date: Tue, 6 Aug 2024 09:55:54 +0200 Subject: [PATCH] WIP Signed-off-by: Camila Ayres --- src/libsync/filesystem.cpp | 29 ++++++++++++++++++++++++++++- src/libsync/logger.cpp | 4 ++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index cc65bf136..3a46b7f3d 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -319,11 +319,35 @@ bool FileSystem::setFolderPermissions(const QString &path, FileSystem::FolderPermissions permissions) noexcept { static constexpr auto writePerms = std::filesystem::perms::owner_write | std::filesystem::perms::group_write | std::filesystem::perms::others_write; + const auto stdStrPath = path.toStdWString(); + auto currentperms = std::filesystem::status(stdStrPath).permissions(); + const auto demp = [=](std::filesystem::perms p){ + QString permstring; + auto show = [&permstring, &p](QString op, std::filesystem::perms perm) + { + permstring.append(std::filesystem::perms::none == (perm & p) ? "-" : op); + }; + show("r", std::filesystem::perms::owner_read); + show("w", std::filesystem::perms::owner_write); + show("x", std::filesystem::perms::owner_exec); + show("r", std::filesystem::perms::group_read); + show("w", std::filesystem::perms::group_write); + show("x", std::filesystem::perms::group_exec); + show("r", std::filesystem::perms::others_read); + show("w", std::filesystem::perms::others_write); + show("x", std::filesystem::perms::others_exec); + + qCWarning(lcFileSystem()) << "path:" << stdStrPath << " - perms:" << permstring; + }; + demp(currentperms); try { switch (permissions) { case OCC::FileSystem::FolderPermissions::ReadOnly: + qCWarning(lcFileSystem()) << "removing write perms to" << stdStrPath; std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::remove); + currentperms = std::filesystem::status(stdStrPath).permissions(); + demp(currentperms); break; case OCC::FileSystem::FolderPermissions::ReadWrite: break; @@ -456,7 +480,10 @@ bool FileSystem::setFolderPermissions(const QString &path, case OCC::FileSystem::FolderPermissions::ReadOnly: break; case OCC::FileSystem::FolderPermissions::ReadWrite: - std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::add); + qCWarning(lcFileSystem()) << "adding write perms to" << stdStrPath; + std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::add); + currentperms = std::filesystem::status(stdStrPath).permissions(); + demp(currentperms); break; } } catch (const std::filesystem::filesystem_error &e) { diff --git a/src/libsync/logger.cpp b/src/libsync/logger.cpp index 64acb2b7b..15f3f7301 100644 --- a/src/libsync/logger.cpp +++ b/src/libsync/logger.cpp @@ -141,6 +141,10 @@ void Logger::doLog(QtMsgType type, const QMessageLogContext &ctx, const QString msgW.append(L"\n"); OutputDebugString(msgW.c_str()); } +#endif +#if defined NEXTCLOUD_DEV || defined QT_DEBUG + QTextStream cout(stdout, QIODevice::WriteOnly); + cout << msg << Qt::endl; #endif { QMutexLocker lock(&_mutex);