diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index 2d5f27f76547a..942b635ffeaec 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -194,6 +194,7 @@ bool FileSystem::getInode(const QString &filename, quint64 *inode) return false; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 bool FileSystem::setFolderPermissions(const QString &path, FileSystem::FolderPermissions permissions) noexcept { @@ -330,6 +331,7 @@ bool FileSystem::setFolderPermissions(const QString &path, } #endif +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 try { switch (permissions) { case OCC::FileSystem::FolderPermissions::ReadOnly: @@ -344,6 +346,7 @@ bool FileSystem::setFolderPermissions(const QString &path, qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str(); return false; } +#endif return true; } @@ -361,6 +364,6 @@ bool FileSystem::isFolderReadOnly(const std::filesystem::path &path) noexcept return false; } } - +#endif } // namespace OCC diff --git a/src/libsync/filesystem.h b/src/libsync/filesystem.h index 102a79f5563ce..0a1b68a29a58f 100644 --- a/src/libsync/filesystem.h +++ b/src/libsync/filesystem.h @@ -23,7 +23,9 @@ #include #include +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 #include +#endif class QFile; @@ -101,7 +103,9 @@ namespace FileSystem { bool OWNCLOUDSYNC_EXPORT setFolderPermissions(const QString &path, FileSystem::FolderPermissions permissions) noexcept; +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 bool OWNCLOUDSYNC_EXPORT isFolderReadOnly(const std::filesystem::path &path) noexcept; +#endif } /** @} */ diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 28c0c18c3e769..a4d21a2e3b85c 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -1443,6 +1443,7 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status) || _item->_instruction == CSYNC_INSTRUCTION_NEW || _item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA) { +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 if (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) && !_item->_remotePerm.hasPermission(RemotePermissions::CanRename) && @@ -1494,6 +1495,7 @@ void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status) _item->_errorString = tr("The folder %1 cannot be made read-only: %2").arg(e.path1().c_str(), e.what()); } } +#endif const auto result = propagator()->updateMetadata(*_item); if (!result) { diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index a690650fe523b..1faf04410a2d7 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -673,6 +673,7 @@ void PropagateDownloadFile::startDownload() FileSystem::setFileReadOnly(_tmpFile.fileName(), false); } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 try { const auto newDirPath = std::filesystem::path{_tmpFile.fileName().toStdWString()}; Q_ASSERT(newDirPath.has_parent_path()); @@ -688,6 +689,7 @@ void PropagateDownloadFile::startDownload() emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring())); _needParentFolderRestorePermissions = true; } +#endif if (!_tmpFile.open(QIODevice::Append | QIODevice::Unbuffered)) { qCWarning(lcPropagateDownload) << "could not open temporary file" << _tmpFile.fileName(); @@ -1287,11 +1289,13 @@ void PropagateDownloadFile::downloadFinished() return; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 if (_needParentFolderRestorePermissions) { FileSystem::setFolderPermissions(QString::fromStdWString(_parentPath.wstring()), FileSystem::FolderPermissions::ReadWrite); emit propagator()->touchedFile(QString::fromStdWString(_parentPath.wstring())); _needParentFolderRestorePermissions = false; } +#endif FileSystem::setFileHidden(filename, false); diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h index 23c72f0aebaea..87aec08dca0a8 100644 --- a/src/libsync/propagatedownload.h +++ b/src/libsync/propagatedownload.h @@ -23,7 +23,9 @@ #include #include +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 #include +#endif namespace OCC { class PropagateDownloadEncrypted; @@ -263,7 +265,9 @@ private slots: PropagateDownloadEncrypted *_downloadEncryptedHelper = nullptr; +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 std::filesystem::path _parentPath; +#endif bool _needParentFolderRestorePermissions = false; }; } diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 41b253bb09874..cb78dfc1184ca 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -32,7 +32,9 @@ #include #include +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 #include +#endif #include @@ -184,6 +186,7 @@ void PropagateLocalMkdir::startLocalMkdir() return; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 auto parentFolderPath = std::filesystem::path{}; auto parentNeedRollbackPermissions = false; try { @@ -200,6 +203,7 @@ void PropagateLocalMkdir::startLocalMkdir() { qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str(); } +#endif emit propagator()->touchedFile(newDirStr); QDir localDir(propagator()->localPath()); @@ -208,6 +212,7 @@ void PropagateLocalMkdir::startLocalMkdir() return; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 if (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanAddFile) && !_item->_remotePerm.hasPermission(RemotePermissions::CanRename) && @@ -234,6 +239,7 @@ void PropagateLocalMkdir::startLocalMkdir() { qCWarning(lcPropagateLocalMkdir) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str(); } +#endif // Insert the directory into the database. The correct etag will be set later, // once all contents have been propagated, because should_update_metadata is true. @@ -304,6 +310,7 @@ void PropagateLocalRename::start() return; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 auto targetParentFolderPath = std::filesystem::path{}; auto targetParentFolderWasReadOnly = false; try { @@ -348,27 +355,31 @@ void PropagateLocalRename::start() qCWarning(lcPropagateLocalRename) << "exception when checking parent folder access rights" << e.what() << e.path1().c_str() << e.path2().c_str(); } }; +#endif emit propagator()->touchedFile(existingFile); emit propagator()->touchedFile(targetFile); if (QString renameError; !FileSystem::rename(existingFile, targetFile, &renameError)) { +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 if (targetParentFolderWasReadOnly) { restoreTargetPermissions(targetParentFolderPath); } if (originParentFolderWasReadOnly) { restoreTargetPermissions(originParentFolderPath); } - +#endif done(SyncFileItem::NormalError, renameError, ErrorCategory::GenericError); return; } +#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15 if (targetParentFolderWasReadOnly) { restoreTargetPermissions(targetParentFolderPath); } if (originParentFolderWasReadOnly) { restoreTargetPermissions(originParentFolderPath); } +#endif } SyncJournalFileRecord oldRecord;