mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
More cleanup of csync remains
This commit is contained in:
parent
01f35bdbef
commit
eb669c997e
@ -33,6 +33,8 @@
|
||||
#include "syncengine.h"
|
||||
#include "common/syncjournaldb.h"
|
||||
#include "config.h"
|
||||
#include "csync_exclude.h"
|
||||
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "csync_private.h"
|
||||
#include "csync.h"
|
||||
|
||||
|
||||
#include "common/syncjournalfilerecord.h"
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "c_private.h"
|
||||
#include "c_utf8.h"
|
||||
|
||||
#include "csync_private.h"
|
||||
#include "csync_exclude.h"
|
||||
#include "csync_misc.h"
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#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: */
|
||||
@ -33,6 +33,8 @@
|
||||
#include "common/c_jhash.h"
|
||||
#include "csync_util.h"
|
||||
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
Q_LOGGING_CATEGORY(lcCSyncUtils, "sync.csync.utils", QtInfoMsg)
|
||||
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "csync_private.h"
|
||||
#include "csync.h"
|
||||
|
||||
const char OCSYNC_EXPORT *csync_instruction_str(enum csync_instructions_e instr);
|
||||
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
#include "vio/csync_vio_local.h"
|
||||
|
||||
#include <QtCore/QLoggingCategory>
|
||||
|
||||
Q_LOGGING_CATEGORY(lcCSyncVIOLocal, "sync.csync.vio_local", QtInfoMsg)
|
||||
|
||||
/*
|
||||
|
||||
@ -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,
|
||||
@ -658,7 +657,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);
|
||||
@ -794,11 +792,6 @@ void Folder::slotSyncStarted()
|
||||
emit syncStateChange();
|
||||
}
|
||||
|
||||
void Folder::slotCsyncUnavailable()
|
||||
{
|
||||
_csyncUnavail = true;
|
||||
}
|
||||
|
||||
void Folder::slotSyncFinished(bool success)
|
||||
{
|
||||
qCInfo(lcFolder) << "Client version" << qPrintable(Theme::instance()->version())
|
||||
@ -819,9 +812,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) {
|
||||
|
||||
@ -22,8 +22,6 @@
|
||||
#include "common/syncjournaldb.h"
|
||||
#include "networkjobs.h"
|
||||
|
||||
#include <csync.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QUuid>
|
||||
@ -305,8 +303,6 @@ private slots:
|
||||
*/
|
||||
void slotSyncError(const QString &message, ErrorCategory category = ErrorCategory::Normal);
|
||||
|
||||
void slotCsyncUnavailable();
|
||||
|
||||
void slotTransmissionProgress(const ProgressInfo &pi);
|
||||
void slotItemCompleted(const SyncFileItemPtr &);
|
||||
|
||||
@ -369,7 +365,6 @@ private:
|
||||
|
||||
SyncResult _syncResult;
|
||||
QScopedPointer<SyncEngine> _engine;
|
||||
bool _csyncUnavail;
|
||||
QPointer<RequestEtagJob> _requestEtagJob;
|
||||
QString _lastEtag;
|
||||
QElapsedTimer _timeSinceLastSyncDone;
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "common/asserts.h"
|
||||
#include "common/checksums.h"
|
||||
|
||||
#include <csync_private.h>
|
||||
#include <csync_exclude.h>
|
||||
|
||||
#include <QLoggingCategory>
|
||||
@ -344,11 +343,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;
|
||||
}
|
||||
|
||||
@ -32,6 +32,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;
|
||||
|
||||
|
||||
@ -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"
|
||||
@ -103,71 +103,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
|
||||
@ -433,182 +368,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;
|
||||
|
||||
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()) {
|
||||
@ -646,7 +405,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;
|
||||
}
|
||||
@ -659,11 +418,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 {
|
||||
@ -692,7 +451,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!
|
||||
@ -708,7 +467,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;
|
||||
}
|
||||
@ -720,7 +479,7 @@ void SyncEngine::startSync()
|
||||
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;
|
||||
}
|
||||
@ -747,7 +506,7 @@ void SyncEngine::startSync()
|
||||
_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;
|
||||
}
|
||||
@ -769,7 +528,7 @@ void SyncEngine::startSync()
|
||||
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);
|
||||
});
|
||||
|
||||
@ -841,7 +600,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 {
|
||||
@ -955,7 +714,7 @@ void SyncEngine::slotDiscoveryJobFinished()
|
||||
|
||||
void SyncEngine::slotCleanPollsJobAborted(const QString &error)
|
||||
{
|
||||
csyncError(error);
|
||||
syncError(error);
|
||||
finalize(false);
|
||||
}
|
||||
|
||||
@ -983,7 +742,7 @@ void SyncEngine::slotItemCompleted(const SyncFileItemPtr &item)
|
||||
_progressInfo->setProgressComplete(*item);
|
||||
|
||||
if (item->_status == SyncFileItem::FatalError) {
|
||||
csyncError(item->_errorString);
|
||||
syncError(item->_errorString);
|
||||
}
|
||||
|
||||
emit transmissionProgress(*_progressInfo);
|
||||
@ -1025,7 +784,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;
|
||||
|
||||
@ -13,8 +13,7 @@
|
||||
* for more details.
|
||||
*/
|
||||
|
||||
#ifndef CSYNCTHREAD_H
|
||||
#define CSYNCTHREAD_H
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -27,11 +26,6 @@
|
||||
#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);
|
||||
|
||||
@ -128,8 +120,6 @@ public:
|
||||
LocalDiscoveryStyle lastLocalDiscoveryStyle() const { return _lastLocalDiscoveryStyle; }
|
||||
|
||||
signals:
|
||||
void csyncUnavailable();
|
||||
|
||||
// During update, before reconcile
|
||||
void rootEtag(QString);
|
||||
|
||||
@ -142,7 +132,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();
|
||||
@ -203,9 +193,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
|
||||
@ -293,9 +280,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. */
|
||||
@ -314,4 +298,3 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSYNCTHREAD_H
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "common/syncjournaldb.h"
|
||||
#include "common/syncjournalfilerecord.h"
|
||||
#include "common/asserts.h"
|
||||
#include "csync_exclude.h"
|
||||
|
||||
#include <QLoggingCategory>
|
||||
|
||||
|
||||
@ -24,8 +24,10 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
|
||||
#include <QtTest>
|
||||
#include "syncenginetestutils.h"
|
||||
#include "csync_exclude.h"
|
||||
|
||||
using namespace OCC;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user