More cleanup of csync remains
authorOlivier Goffart <ogoffart@woboq.com>
Thu, 26 Jul 2018 07:53:40 +0000 (09:53 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:01 +0000 (10:58 +0100)
18 files changed:
src/cmd/cmd.cpp
src/csync/csync.cpp
src/csync/csync_exclude.cpp
src/csync/csync_misc.cpp
src/csync/csync_misc.h
src/csync/csync_private.h [deleted file]
src/csync/csync_util.cpp
src/csync/csync_util.h
src/csync/vio/csync_vio_local_unix.cpp
src/gui/folder.cpp
src/gui/folder.h
src/libsync/discoveryphase.cpp
src/libsync/discoveryphase.h
src/libsync/syncengine.cpp
src/libsync/syncengine.h
src/libsync/syncfilestatustracker.cpp
test/csync/vio_tests/check_vio_ext.cpp
test/testsyncfilestatustracker.cpp

index c521465cc1f0b8803614edb0b1b4fd975e78b1af..3de2c43e3565ad16b08e3d4cbce60f0ffa0e53f2 100644 (file)
@@ -33,6 +33,8 @@
 #include "syncengine.h"
 #include "common/syncjournaldb.h"
 #include "config.h"
+#include "csync_exclude.h"
+
 
 #include "cmd.h"
 
index 3f3d17778da85f6f940ba68144d17352d83c618c..7bb9d9a73495f433c8aedf74181f84421e3710fc 100644 (file)
@@ -25,7 +25,7 @@
 #define _GNU_SOURCE
 #endif
 
-#include "csync_private.h"
+#include "csync.h"
 
 
 #include "common/syncjournalfilerecord.h"
index f3a610ec0ff841ec601bae97fa76f22c8b7d645d..de0216553c157fbb59c3a6af0b67c2a38f5ea8c4 100644 (file)
@@ -28,7 +28,6 @@
 #include "c_private.h"
 #include "c_utf8.h"
 
-#include "csync_private.h"
 #include "csync_exclude.h"
 #include "csync_misc.h"
 
index 1f4f1cc75c6cb69030fa1314dcaf251a5c311846..bd6f9a6d701579565e3ea04b3d5b822a00848f5c 100644 (file)
@@ -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;
-}
index 6b9f98418e98860b6b1bd871aa522720037cf6cd..a68ff7849d30b42a5f4bc4839e321b6f8a835301 100644 (file)
 
 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 (file)
index 1d55af0..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * cynapses libc functions
- *
- * Copyright (c) 2008-2013 by Andreas Schneider <asn@cryptomilk.org>
- * Copyright (c) 2012-2013 by Klaas Freitag <freitag@owncloud.com>
- *
- * 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 <unordered_map>
-#include <QHash>
-#include <cstdint>
-
-#include <map>
-#include <set>
-#include <functional>
-
-#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: */
index d36677b251d02ce97bfc3eb6d14b74a05c62d473..57b9923875366ddc264d0c40c05090d2e71331bc 100644 (file)
@@ -33,6 +33,8 @@
 #include "common/c_jhash.h"
 #include "csync_util.h"
 
+#include <QtCore/QLoggingCategory>
+
 Q_LOGGING_CATEGORY(lcCSyncUtils, "nextcloud.sync.csync.utils", QtInfoMsg)
 
 
index bef83b54d96b134a170148faa1d1cf0a6e4dbaa8..0114ed2b4cede75b5cf16c0291287a33750ed7cd 100644 (file)
@@ -24,7 +24,7 @@
 
 #include <cstdint>
 
-#include "csync_private.h"
+#include "csync.h"
 
 const char OCSYNC_EXPORT *csync_instruction_str(enum csync_instructions_e instr);
 
index a3eaade75cf4d0770deb038cbb8f445a3d3e3784..c13b0fab7b8e34f1632df007dd8569327f4ec8b5 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "vio/csync_vio_local.h"
 
+#include <QtCore/QLoggingCategory>
+
 Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "nextcloud.sync.csync.vio_local", QtInfoMsg)
 
 /*
index 56fa5640128439ab984c4163083f3ffd869ebdc7..1ff7e8af7303411d3468918a58564b5520fb7756 100644 (file)
@@ -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) {
index 46d3499e3c9d8d8581d69f8bbe1d34fda8e28734..734d709ab7036e929d57895c08308c4f4588c20c 100644 (file)
@@ -22,8 +22,6 @@
 #include "common/syncjournaldb.h"
 #include "networkjobs.h"
 
-#include <csync.h>
-
 #include <QObject>
 #include <QStringList>
 #include <QUuid>
@@ -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<SyncEngine> _engine;
-    bool _csyncUnavail;
     QPointer<RequestEtagJob> _requestEtagJob;
     QString _lastEtag;
     QElapsedTimer _timeSinceLastSyncDone;
index a784a7ad9ce0221ba3244ff2d15cad305b34cb65..047fc8ea75028ce12805f183a397c74ff6b8d6f1 100644 (file)
@@ -18,7 +18,6 @@
 #include "common/asserts.h"
 #include "common/checksums.h"
 
-#include <csync_private.h>
 #include <csync_exclude.h>
 
 #include <QLoggingCategory>
@@ -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;
     }
index 5cf9550df2c01e4e0fede7168e357b700c3f5b15..94ca1b640228101a5bdbb60833fc903fc6de1be9 100644 (file)
@@ -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;
 
index dc8380a12083546fc0fa23a8075f63421f8e3a5f..846374ef98ae757fa89e323e530d0feaf75e858a 100644 (file)
@@ -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;
index 61ec37289b8203e76c2a0d61173f1407d22c649f..d3d1aca70688bf126950eff163748e40099c242d 100644 (file)
@@ -13,8 +13,7 @@
  * for more details.
  */
 
-#ifndef CSYNCTHREAD_H
-#define CSYNCTHREAD_H
+#pragma once
 
 #include <cstdint>
 
 #include <QSharedPointer>
 #include <set>
 
-#include <csync.h>
-
-// when do we go away with this private/public separation?
-#include <csync_private.h>
-
 #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
index ecafde7000ea7aed4166dc483e11934615ba66cf..78ecba389fd94a9d818b3eae761e2b6374858d53 100644 (file)
@@ -18,6 +18,7 @@
 #include "common/syncjournaldb.h"
 #include "common/syncjournalfilerecord.h"
 #include "common/asserts.h"
+#include "csync_exclude.h"
 
 #include <QLoggingCategory>
 
index 6d02ae21041bbb7d285f85ae71bdb513b03f8812..85a31215e74018496ac8255a3e62b31d861119dd 100644 (file)
 #include <cerrno>
 #include <cstdio>
 
-#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
index b55876fad0c1950fa583420763c90d36be777437..4f1f8c0703f54efb47b63ddb9da91e34b7eae152 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <QtTest>
 #include "syncenginetestutils.h"
+#include "csync_exclude.h"
 
 using namespace OCC;