From: Olivier Goffart Date: Thu, 26 Jul 2018 07:53:40 +0000 (+0200) Subject: More cleanup of csync remains X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~538 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ca32eb1cf779584dd707ba7ccb569c4a1839e91e;p=nextcloud-desktop.git More cleanup of csync remains --- diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index c521465cc..3de2c43e3 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -33,6 +33,8 @@ #include "syncengine.h" #include "common/syncjournaldb.h" #include "config.h" +#include "csync_exclude.h" + #include "cmd.h" diff --git a/src/csync/csync.cpp b/src/csync/csync.cpp index 3f3d17778..7bb9d9a73 100644 --- a/src/csync/csync.cpp +++ b/src/csync/csync.cpp @@ -25,7 +25,7 @@ #define _GNU_SOURCE #endif -#include "csync_private.h" +#include "csync.h" #include "common/syncjournalfilerecord.h" diff --git a/src/csync/csync_exclude.cpp b/src/csync/csync_exclude.cpp index f3a610ec0..de0216553 100644 --- a/src/csync/csync_exclude.cpp +++ b/src/csync/csync_exclude.cpp @@ -28,7 +28,6 @@ #include "c_private.h" #include "c_utf8.h" -#include "csync_private.h" #include "csync_exclude.h" #include "csync_misc.h" diff --git a/src/csync/csync_misc.cpp b/src/csync/csync_misc.cpp index 1f4f1cc75..bd6f9a6d7 100644 --- a/src/csync/csync_misc.cpp +++ b/src/csync/csync_misc.cpp @@ -69,79 +69,3 @@ int csync_fnmatch(const char *pattern, const char *name, int flags) { } #endif /* HAVE_FNMATCH */ -CSYNC_STATUS csync_errno_to_status(int error, CSYNC_STATUS default_status) -{ - CSYNC_STATUS status = CSYNC_STATUS_OK; - - switch (error) { - case 0: - status = CSYNC_STATUS_OK; - break; - /* The custom errnos first. */ - case ERRNO_SERVICE_UNAVAILABLE: - status = CSYNC_STATUS_SERVICE_UNAVAILABLE; /* Service temporarily down */ - break; - case ERRNO_STORAGE_UNAVAILABLE: - status = CSYNC_STATUS_STORAGE_UNAVAILABLE; /* Storage temporarily unavailable */ - break; - case EFBIG: - status = CSYNC_STATUS_FILE_SIZE_ERROR; /* File larger than 2MB */ - break; - case ERRNO_WRONG_CONTENT: - status = CSYNC_STATUS_HTTP_ERROR; - break; - - case EPERM: /* Operation not permitted */ - case EACCES: /* Permission denied */ - status = CSYNC_STATUS_PERMISSION_DENIED; - break; - case ENOENT: /* No such file or directory */ - status = CSYNC_STATUS_NOT_FOUND; - break; - case EAGAIN: /* Try again */ - status = CSYNC_STATUS_TIMEOUT; - break; - case EEXIST: /* File exists */ - status = CSYNC_STATUS_FILE_EXISTS; - break; - case ENOSPC: - status = CSYNC_STATUS_OUT_OF_SPACE; - break; - - /* All the remaining basic errnos: */ - case EINVAL: /* Invalid argument */ - case EIO: /* I/O error */ - case ESRCH: /* No such process */ - case EINTR: /* Interrupted system call */ - case ENXIO: /* No such device or address */ - case E2BIG: /* Argument list too long */ - case ENOEXEC: /* Exec format error */ - case EBADF: /* Bad file number */ - case ECHILD: /* No child processes */ - case ENOMEM: /* Out of memory */ - case EFAULT: /* Bad address */ -#ifndef _WIN32 - case ENOTBLK: /* Block device required */ -#endif - case EBUSY: /* Device or resource busy */ - case EXDEV: /* Cross-device link */ - case ENODEV: /* No such device */ - case ENOTDIR: /* Not a directory */ - case EISDIR: /* Is a directory */ - case ENFILE: /* File table overflow */ - case EMFILE: /* Too many open files */ - case ENOTTY: /* Not a typewriter */ -#ifndef _WIN32 - case ETXTBSY: /* Text file busy */ -#endif - case ESPIPE: /* Illegal seek */ - case EROFS: /* Read-only file system */ - case EMLINK: /* Too many links */ - case EPIPE: /* Broken pipe */ - - default: - status = default_status; - } - - return status; -} diff --git a/src/csync/csync_misc.h b/src/csync/csync_misc.h index 6b9f98418..a68ff7849 100644 --- a/src/csync/csync_misc.h +++ b/src/csync/csync_misc.h @@ -38,14 +38,4 @@ int csync_fnmatch(const char *pattern, const char *name, int flags); -/** - * @brief csync_errno_to_status - errno to csync status code - * - * This function tries to convert the value of the current set errno - * to a csync status code. - * - * @return the corresponding csync error code. - */ -CSYNC_STATUS csync_errno_to_status(int error, CSYNC_STATUS default_status); - #endif /* _CSYNC_MISC_H */ diff --git a/src/csync/csync_private.h b/src/csync/csync_private.h deleted file mode 100644 index 1d55af0b0..000000000 --- a/src/csync/csync_private.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * cynapses libc functions - * - * Copyright (c) 2008-2013 by Andreas Schneider - * Copyright (c) 2012-2013 by Klaas Freitag - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file csync_private.h - * - * @brief Private interface of csync - * - * @defgroup csyncInternalAPI csync internal API - * - * @{ - */ - -#ifndef _CSYNC_PRIVATE_H -#define _CSYNC_PRIVATE_H - -#include -#include -#include - -#include -#include -#include - -#include "common/syncjournaldb.h" -#include "config_csync.h" -#include "std/c_lib.h" -#include "std/c_private.h" -#include "csync.h" -#include "csync_misc.h" -#include "csync_exclude.h" -#include "csync_macros.h" - -/** - * How deep to scan directories. - */ -#define MAX_DEPTH 100 - -#define CSYNC_STATUS_INIT 1 << 0 -#define CSYNC_STATUS_UPDATE 1 << 1 -#define CSYNC_STATUS_RECONCILE 1 << 2 -#define CSYNC_STATUS_PROPAGATE 1 << 3 - -#define CSYNC_STATUS_DONE (CSYNC_STATUS_INIT | \ - CSYNC_STATUS_UPDATE | \ - CSYNC_STATUS_RECONCILE | \ - CSYNC_STATUS_PROPAGATE) - -enum csync_replica_e { - LOCAL_REPLICA, - REMOTE_REPLICA -}; - -enum class LocalDiscoveryStyle { - FilesystemOnly, //< read all local data from the filesystem - DatabaseAndFilesystem, //< read from the db, except for listed paths -}; - - -/* - * This is a structurere similar to QStringRef - * The difference is that it keeps the QByteArray by value and not by pointer - * And it only implements a very small subset of the API that is required by csync, the API can be - * added as we need it. - */ -class ByteArrayRef -{ - QByteArray _arr; - int _begin = 0; - int _size = -1; - - /* Pointer to the beginning of the data. WARNING: not null terminated */ - const char *data() const { return _arr.constData() + _begin; } - friend struct ByteArrayRefHash; - -public: - ByteArrayRef(QByteArray arr = {}, int begin = 0, int size = -1) - : _arr(std::move(arr)) - , _begin(begin) - , _size(qMin(_arr.size() - begin, size < 0 ? _arr.size() - begin : size)) - { - } - ByteArrayRef left(int l) const { return ByteArrayRef(_arr, _begin, l); }; - char at(int x) const { return _arr.at(_begin + x); } - int size() const { return _size; } - int length() const { return _size; } - bool isEmpty() const { return _size == 0; } - - friend bool operator==(const ByteArrayRef &a, const ByteArrayRef &b) - { return a.size() == b.size() && qstrncmp(a.data(), b.data(), a.size()) == 0; } -}; -struct ByteArrayRefHash { uint operator()(const ByteArrayRef &a) const { return qHashBits(a.data(), a.size()); } }; - -/** - * @brief csync public structure - */ -struct OCSYNC_EXPORT csync_s { - - - // For some reason MSVC references the copy constructor and/or the assignment operator - // if a class is exported. This is a problem since unique_ptr isn't copyable. - // Explicitly disable them to fix the issue. - // https://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/e39ab33d-1aaf-4125-b6de-50410d9ced1d - csync_s(const csync_s &) = delete; - csync_s &operator=(const csync_s &) = delete; -}; - -void set_errno_from_http_errcode( int err ); - -/** - * }@ - */ -#endif /* _CSYNC_PRIVATE_H */ -/* vim: set ft=c.doxygen ts=8 sw=2 et cindent: */ diff --git a/src/csync/csync_util.cpp b/src/csync/csync_util.cpp index d36677b25..57b992387 100644 --- a/src/csync/csync_util.cpp +++ b/src/csync/csync_util.cpp @@ -33,6 +33,8 @@ #include "common/c_jhash.h" #include "csync_util.h" +#include + Q_LOGGING_CATEGORY(lcCSyncUtils, "nextcloud.sync.csync.utils", QtInfoMsg) diff --git a/src/csync/csync_util.h b/src/csync/csync_util.h index bef83b54d..0114ed2b4 100644 --- a/src/csync/csync_util.h +++ b/src/csync/csync_util.h @@ -24,7 +24,7 @@ #include -#include "csync_private.h" +#include "csync.h" const char OCSYNC_EXPORT *csync_instruction_str(enum csync_instructions_e instr); diff --git a/src/csync/vio/csync_vio_local_unix.cpp b/src/csync/vio/csync_vio_local_unix.cpp index a3eaade75..c13b0fab7 100644 --- a/src/csync/vio/csync_vio_local_unix.cpp +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -36,6 +36,8 @@ #include "vio/csync_vio_local.h" +#include + Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "nextcloud.sync.csync.vio_local", QtInfoMsg) /* diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 56fa56401..1ff7e8af7 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -31,6 +31,7 @@ #include "theme.h" #include "filesystem.h" #include "localdiscoverytracker.h" +#include "csync_exclude.h" #include "creds/abstractcredentials.h" @@ -54,7 +55,6 @@ Folder::Folder(const FolderDefinition &definition, : QObject(parent) , _accountState(accountState) , _definition(definition) - , _csyncUnavail(false) , _lastSyncDuration(0) , _consecutiveFailingSyncs(0) , _consecutiveFollowUpSyncs(0) @@ -89,7 +89,6 @@ Folder::Folder(const FolderDefinition &definition, connect(_engine.data(), &SyncEngine::started, this, &Folder::slotSyncStarted, Qt::QueuedConnection); connect(_engine.data(), &SyncEngine::finished, this, &Folder::slotSyncFinished, Qt::QueuedConnection); - connect(_engine.data(), &SyncEngine::csyncUnavailable, this, &Folder::slotCsyncUnavailable, Qt::QueuedConnection); //direct connection so the message box is blocking the sync. connect(_engine.data(), &SyncEngine::aboutToRemoveAllFiles, @@ -668,7 +667,6 @@ void Folder::startSync(const QStringList &pathList) qCCritical(lcFolder) << "ERROR csync is still running and new sync requested."; return; } - _csyncUnavail = false; _timeSinceLastSyncStart.start(); _syncResult.setStatus(SyncResult::SyncPrepare); @@ -804,11 +802,6 @@ void Folder::slotSyncStarted() emit syncStateChange(); } -void Folder::slotCsyncUnavailable() -{ - _csyncUnavail = true; -} - void Folder::slotSyncFinished(bool success) { qCInfo(lcFolder) << "Client version" << qPrintable(Theme::instance()->version()) @@ -829,9 +822,6 @@ void Folder::slotSyncFinished(bool success) if (syncError) { _syncResult.setStatus(SyncResult::Error); - } else if (_csyncUnavail) { - _syncResult.setStatus(SyncResult::Error); - qCWarning(lcFolder) << "csync not available."; } else if (_syncResult.foundFilesNotSynced()) { _syncResult.setStatus(SyncResult::Problem); } else if (_definition.paused) { diff --git a/src/gui/folder.h b/src/gui/folder.h index 46d3499e3..734d709ab 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -22,8 +22,6 @@ #include "common/syncjournaldb.h" #include "networkjobs.h" -#include - #include #include #include @@ -299,8 +297,6 @@ private slots: */ void slotSyncError(const QString &message, ErrorCategory category = ErrorCategory::Normal); - void slotCsyncUnavailable(); - void slotTransmissionProgress(const ProgressInfo &pi); void slotItemCompleted(const SyncFileItemPtr &); @@ -364,7 +360,6 @@ private: SyncResult _syncResult; QScopedPointer _engine; - bool _csyncUnavail; QPointer _requestEtagJob; QString _lastEtag; QElapsedTimer _timeSinceLastSyncDone; diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index a784a7ad9..047fc8ea7 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -18,7 +18,6 @@ #include "common/asserts.h" #include "common/checksums.h" -#include #include #include @@ -347,11 +346,11 @@ void DiscoverySingleDirectoryJob::lsJobFinishedWithoutErrorSlot() if (!_ignoredFirst) { // This is a sanity check, if we haven't _ignoredFirst then it means we never received any directoryListingIteratedSlot // which means somehow the server XML was bogus - emit finished({ERRNO_WRONG_CONTENT, tr("Server error: PROPFIND reply is not XML formatted!")}); + emit finished({ 0, tr("Server error: PROPFIND reply is not XML formatted!") }); deleteLater(); return; } else if (!_error.isEmpty()) { - emit finished({ERRNO_WRONG_CONTENT, _error}); + emit finished({ 0, _error }); deleteLater(); return; } diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 5cf9550df..94ca1b640 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -31,6 +31,12 @@ class ExcludedFiles; namespace OCC { +enum class LocalDiscoveryStyle { + FilesystemOnly, //< read all local data from the filesystem + DatabaseAndFilesystem, //< read from the db, except for listed paths +}; + + class Account; class SyncJournalDb; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index dc8380a12..846374ef9 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -21,7 +21,7 @@ #include "discoveryphase.h" #include "creds/abstractcredentials.h" #include "syncfilestatus.h" -#include "csync_private.h" +#include "csync_exclude.h" #include "filesystem.h" #include "propagateremotedelete.h" #include "propagatedownload.h" @@ -104,71 +104,6 @@ SyncEngine::~SyncEngine() _excludedFiles.reset(); } -//Convert an error code from csync to a user readable string. -// Keep that function thread safe as it can be called from the sync thread or the main thread -QString SyncEngine::csyncErrorToString(CSYNC_STATUS err) -{ - QString errStr; - - switch (err) { - case CSYNC_STATUS_OK: - errStr = tr("Success."); - break; - case CSYNC_STATUS_STATEDB_LOAD_ERROR: - errStr = tr("Failed to load or create the journal file. " - "Make sure you have read and write permissions in the local sync folder."); - break; - case CSYNC_STATUS_UPDATE_ERROR: - errStr = tr("Discovery step failed."); - break; - case CSYNC_STATUS_TIMEOUT: - errStr = tr("A network connection timeout happened."); - break; - case CSYNC_STATUS_HTTP_ERROR: - errStr = tr("A HTTP transmission error happened."); - break; - case CSYNC_STATUS_PERMISSION_DENIED: - errStr = tr("Permission denied."); - break; - case CSYNC_STATUS_NOT_FOUND: - errStr = tr("File or directory not found:") + " "; // filename gets added. - break; - case CSYNC_STATUS_FILE_EXISTS: - errStr = tr("Tried to create a folder that already exists."); - break; - case CSYNC_STATUS_OUT_OF_SPACE: - errStr = tr("No space on %1 server available.").arg(qApp->applicationName()); - break; - case CSYNC_STATUS_UNSUCCESSFUL: - errStr = tr("CSync unspecified error."); - break; - case CSYNC_STATUS_ABORTED: - errStr = tr("Aborted by the user"); - break; - case CSYNC_STATUS_SERVICE_UNAVAILABLE: - errStr = tr("The service is temporarily unavailable"); - break; - case CSYNC_STATUS_STORAGE_UNAVAILABLE: - errStr = tr("The mounted folder is temporarily not available on the server"); - break; - case CSYNC_STATUS_FORBIDDEN: - errStr = tr("Access is forbidden"); - break; - case CSYNC_STATUS_OPENDIR_ERROR: - errStr = tr("An error occurred while opening a folder"); - break; - case CSYNC_STATUS_READDIR_ERROR: - errStr = tr("Error while reading folder."); - break; - case CSYNC_STATUS_INVALID_CHARACTERS: - // Handled in callee - default: - errStr = tr("An internal error number %1 occurred.").arg((int)err); - } - - return errStr; -} - /** * Check if the item is in the blacklist. * If it should not be sync'ed because of the blacklist, update the item with the error instruction @@ -439,183 +374,6 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) slotNewItem(item); } - -/** - * The main function in the post-reconcile phase. - * - * Called on each entry in the local and remote trees by - * csync_walk_local_tree()/csync_walk_remote_tree(). - * - * It merges the two csync file trees into a single map of SyncFileItems. - * - * See doc/dev/sync-algorithm.md for an overview. - */ -int SyncEngine::treewalkFile(csync_file_stat_t * /*file*/, csync_file_stat_t * /*other*/, bool /*remote*/) -{ -#if 0 // FIXME adapt - if (!file) - return -1; - - auto instruction = file->instruction; - - // Decode utf8 path and rename_path QByteArrays to QStrings - QString fileUtf8; - QString renameTarget; - - - // key is the handle that the SyncFileItem will have in the map. - QString key = fileUtf8; - if (instruction == CSYNC_INSTRUCTION_RENAME) { - key = renameTarget; - } - - // Gets a default-constructed SyncFileItemPtr or the one from the first walk (=local walk) - SyncFileItemPtr item = _syncItemMap.value(key); - if (!item) - item = SyncFileItemPtr(new SyncFileItem); - - if (item->_file.isEmpty() || instruction == CSYNC_INSTRUCTION_RENAME) { - item->_file = fileUtf8; - } - item->_originalFile = item->_file; - item->_encryptedFileName = file->e2eMangledName; - - if (item->_instruction == CSYNC_INSTRUCTION_NONE - || (item->_instruction == CSYNC_INSTRUCTION_IGNORE && instruction != CSYNC_INSTRUCTION_NONE)) { - // Take values from side (local/remote) where instruction is not _NONE - item->_instruction = instruction; - item->_modtime = file->modtime; - item->_size = file->size; - item->_checksumHeader = file->checksumHeader; - item->_type = file->type; - } else { - if (instruction != CSYNC_INSTRUCTION_NONE) { - qCWarning(lcEngine) << "ERROR: Instruction" << item->_instruction << "vs" << instruction << "for" << fileUtf8; - ASSERT(false); - // Set instruction to NONE for safety. - file->instruction = item->_instruction = instruction = CSYNC_INSTRUCTION_NONE; - return -1; // should lead to treewalk error - } - } - - if (!file->file_id.isEmpty()) { - item->_fileId = file->file_id; - } - if (!file->directDownloadUrl.isEmpty()) { - item->_directDownloadUrl = QString::fromUtf8(file->directDownloadUrl); - } - if (!file->directDownloadCookies.isEmpty()) { - item->_directDownloadCookies = QString::fromUtf8(file->directDownloadCookies); - } - if (!file->remotePerm.isNull()) { - item->_remotePerm = file->remotePerm; - } - - /* The flag "serverHasIgnoredFiles" is true if item in question is a directory - * that has children which are ignored in sync, either because the files are - * matched by an ignore pattern, or because they are hidden. - * - * Only the information about the server side ignored files is stored to the - * database and thus written to the item here. For the local repository its - * generated by the walk through the real file tree by discovery phase. - * - * It needs to go to the sync journal becasue the stat information about remote - * files are often read from database rather than being pulled from remote. - */ - if (remote) { - item->_serverHasIgnoredFiles = file->has_ignored_files; - } - - - - switch (file->error_status) { - - case CSYNC_STATUS_INDIVIDUAL_IS_SYMLINK: - item->_errorString = tr("Symbolic links are not supported in syncing."); - break; - - case CSYNC_STATUS_INDIVIDUAL_TOO_DEEP: - item->_errorString = tr("Folder hierarchy is too deep"); - break; - case CSYNC_STATUS_SERVICE_UNAVAILABLE: - item->_errorString = QLatin1String("Server temporarily unavailable."); - break; - case CSYNC_STATUS_STORAGE_UNAVAILABLE: - item->_errorString = QLatin1String("Directory temporarily not available on server."); - item->_status = SyncFileItem::SoftError; - _temporarilyUnavailablePaths.insert(item->_file); - break; - case CSYNC_STATUS_FORBIDDEN: - item->_errorString = QLatin1String("Access forbidden."); - item->_status = SyncFileItem::SoftError; - _temporarilyUnavailablePaths.insert(item->_file); - break; - - } - - - - bool isDirectory = file->type == ItemTypeDirectory; - - if (!file->etag.isEmpty()) { - item->_etag = file->etag; - } - - - if (!item->_inode) { - item->_inode = file->inode; - } - - SyncFileItem::Direction dir = SyncFileItem::None; - - int re = 0; - switch (file->instruction) { - case CSYNC_INSTRUCTION_NONE: { - ... ported .... - } - case CSYNC_INSTRUCTION_UPDATE_METADATA: - dir = SyncFileItem::None; - - ... ported ... - - break; - case CSYNC_INSTRUCTION_RENAME: - dir = !remote ? SyncFileItem::Down : SyncFileItem::Up; - item->_renameTarget = renameTarget; - if (isDirectory) - _renamedFolders.insert(item->_file, item->_renameTarget); - break; - case CSYNC_INSTRUCTION_REMOVE: - - dir = !remote ? SyncFileItem::Down : SyncFileItem::Up; - break; - case CSYNC_INSTRUCTION_CONFLICT: - case CSYNC_INSTRUCTION_ERROR: - dir = SyncFileItem::None; - break; - case CSYNC_INSTRUCTION_NEW: - case CSYNC_INSTRUCTION_EVAL: - case CSYNC_INSTRUCTION_STAT_ERROR: - case CSYNC_INSTRUCTION_IGNORE: - default: - dir = remote ? SyncFileItem::Down : SyncFileItem::Up; - break; - } - - - - slotNewItem(item); - _syncItemMap.insert(key, item); - return re; -#endif - return 0; -} - -void SyncEngine::csyncError(const QString &message) -{ - emit syncError(message, ErrorCategory::Normal); -} - void SyncEngine::startSync() { if (_journal->exists()) { @@ -653,7 +411,7 @@ void SyncEngine::startSync() if (!QDir(_localPath).exists()) { _anotherSyncNeeded = DelayedFollowUp; // No _tr, it should only occur in non-mirall - csyncError("Unable to find local sync folder."); + syncError("Unable to find local sync folder."); finalize(false); return; } @@ -666,11 +424,11 @@ void SyncEngine::startSync() qCWarning(lcEngine()) << "Too little space available at" << _localPath << ". Have" << freeBytes << "bytes and require at least" << minFree << "bytes"; _anotherSyncNeeded = DelayedFollowUp; - csyncError(tr("Only %1 are available, need at least %2 to start", + syncError(tr("Only %1 are available, need at least %2 to start", "Placeholders are postfixed with file sizes using Utility::octetsToString()") - .arg( - Utility::octetsToString(freeBytes), - Utility::octetsToString(minFree))); + .arg( + Utility::octetsToString(freeBytes), + Utility::octetsToString(minFree))); finalize(false); return; } else { @@ -699,7 +457,7 @@ void SyncEngine::startSync() // This creates the DB if it does not exist yet. if (!_journal->isConnected()) { qCWarning(lcEngine) << "No way to create a sync journal!"; - csyncError(tr("Unable to open or create the local sync database. Make sure you have write access in the sync folder.")); + syncError(tr("Unable to open or create the local sync database. Make sure you have write access in the sync folder.")); finalize(false); return; // database creation error! @@ -715,7 +473,7 @@ void SyncEngine::startSync() _lastLocalDiscoveryStyle = _localDiscoveryStyle; if (_syncOptions._newFilesAreVirtual && _syncOptions._virtualFileSuffix.isEmpty()) { - csyncError(tr("Using virtual files but suffix is not set")); + syncError(tr("Using virtual files but suffix is not set")); finalize(false); return; } @@ -790,7 +548,7 @@ void SyncEngine::slotStartDiscovery() qCInfo(lcEngine) << (usingSelectiveSync ? "Using Selective Sync" : "NOT Using Selective Sync"); } else { qCWarning(lcEngine) << "Could not retrieve selective sync list from DB"; - csyncError(tr("Unable to read the blacklist from the local database")); + syncError(tr("Unable to read the blacklist from the local database")); finalize(false); return; } @@ -817,7 +575,7 @@ void SyncEngine::slotStartDiscovery() _discoveryPhase->_shouldDiscoverLocaly = [this](const QString &s) { return shouldDiscoverLocally(s); }; if (!ok) { qCWarning(lcEngine) << "Unable to read selective sync list, aborting."; - csyncError(tr("Unable to read from the sync journal.")); + syncError(tr("Unable to read from the sync journal.")); finalize(false); return; } @@ -839,7 +597,7 @@ void SyncEngine::slotStartDiscovery() connect(_discoveryPhase.data(), &DiscoveryPhase::folderDiscovered, this, &SyncEngine::slotFolderDiscovered); connect(_discoveryPhase.data(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder); connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString) { - csyncError(errorString); + syncError(errorString); finalize(false); }); @@ -911,7 +669,7 @@ void SyncEngine::slotDiscoveryJobFinished() // Sanity check if (!_journal->isConnected()) { qCWarning(lcEngine) << "Bailing out, DB failure"; - csyncError(tr("Cannot open the sync journal")); + syncError(tr("Cannot open the sync journal")); finalize(false); return; } else { @@ -1025,7 +783,7 @@ void SyncEngine::slotDiscoveryJobFinished() void SyncEngine::slotCleanPollsJobAborted(const QString &error) { - csyncError(error); + syncError(error); finalize(false); } @@ -1053,7 +811,7 @@ void SyncEngine::slotItemCompleted(const SyncFileItemPtr &item) _progressInfo->setProgressComplete(*item); if (item->_status == SyncFileItem::FatalError) { - csyncError(item->_errorString); + syncError(item->_errorString); } emit transmissionProgress(*_progressInfo); @@ -1095,7 +853,7 @@ void SyncEngine::finalize(bool success) { _journal->close(); - qCInfo(lcEngine) << "CSync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished")) << "ms"; + qCInfo(lcEngine) << "Sync run took " << _stopWatch.addLapTime(QLatin1String("Sync Finished")) << "ms"; _stopWatch.stop(); s_anySyncRunning = false; diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 61ec37289..d3d1aca70 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -13,8 +13,7 @@ * for more details. */ -#ifndef CSYNCTHREAD_H -#define CSYNCTHREAD_H +#pragma once #include @@ -27,11 +26,6 @@ #include #include -#include - -// when do we go away with this private/public separation? -#include - #include "syncfileitem.h" #include "progressdispatcher.h" #include "common/utility.h" @@ -67,8 +61,6 @@ public: const QString &remotePath, SyncJournalDb *journal); ~SyncEngine(); - static QString csyncErrorToString(CSYNC_STATUS); - Q_INVOKABLE void startSync(); void setNetworkLimits(int upload, int download); @@ -130,8 +122,6 @@ public: auto getPropagator() { return _propagator; } // for the test signals: - void csyncUnavailable(); - // During update, before reconcile void rootEtag(QString); @@ -144,7 +134,7 @@ signals: void transmissionProgress(const ProgressInfo &progress); /// We've produced a new sync error of a type. - void syncError(const QString &message, ErrorCategory category); + void syncError(const QString &message, ErrorCategory category = ErrorCategory::Normal); void finished(bool success); void started(); @@ -208,9 +198,6 @@ private slots: void slotInsufficientRemoteStorage(); private: - void csyncError(const QString &message); - - int treewalkFile(csync_file_stat_t *file, csync_file_stat_t *other, bool); bool checkErrorBlacklisting(SyncFileItem &item); // Cleans up unnecessary downloadinfo entries in the journal as well @@ -298,9 +285,6 @@ private: int _downloadLimit; SyncOptions _syncOptions; - /// Hook for computing checksums from csync_update - CSyncChecksumHook _checksum_hook; - AnotherSyncNeeded _anotherSyncNeeded; /** Stores the time since a job touched a file. */ @@ -319,4 +303,3 @@ private: }; } -#endif // CSYNCTHREAD_H diff --git a/src/libsync/syncfilestatustracker.cpp b/src/libsync/syncfilestatustracker.cpp index ecafde700..78ecba389 100644 --- a/src/libsync/syncfilestatustracker.cpp +++ b/src/libsync/syncfilestatustracker.cpp @@ -18,6 +18,7 @@ #include "common/syncjournaldb.h" #include "common/syncjournalfilerecord.h" #include "common/asserts.h" +#include "csync_exclude.h" #include diff --git a/test/csync/vio_tests/check_vio_ext.cpp b/test/csync/vio_tests/check_vio_ext.cpp index 6d02ae210..85a31215e 100644 --- a/test/csync/vio_tests/check_vio_ext.cpp +++ b/test/csync/vio_tests/check_vio_ext.cpp @@ -24,8 +24,10 @@ #include #include -#include "csync_private.h" +#include "csync.h" #include "std/c_utf8.h" +#include "std/c_alloc.h" +#include "std/c_string.h" #include "vio/csync_vio_local.h" #ifdef _WIN32 diff --git a/test/testsyncfilestatustracker.cpp b/test/testsyncfilestatustracker.cpp index b55876fad..4f1f8c070 100644 --- a/test/testsyncfilestatustracker.cpp +++ b/test/testsyncfilestatustracker.cpp @@ -7,6 +7,7 @@ #include #include "syncenginetestutils.h" +#include "csync_exclude.h" using namespace OCC;