2012-02-15 12:30:37 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2012-05-21 18:48:49 +04:00
|
|
|
#include "mirall/csyncthread.h"
|
2013-10-30 19:31:47 +04:00
|
|
|
#include "mirall/account.h"
|
2012-05-21 18:48:49 +04:00
|
|
|
#include "mirall/mirallconfigfile.h"
|
2012-09-27 19:22:08 +04:00
|
|
|
#include "mirall/theme.h"
|
2012-12-05 19:45:28 +04:00
|
|
|
#include "mirall/logger.h"
|
2013-05-03 21:11:00 +04:00
|
|
|
#include "owncloudpropagator.h"
|
2013-10-03 22:00:58 +04:00
|
|
|
#include "syncjournaldb.h"
|
|
|
|
#include "syncjournalfilerecord.h"
|
2013-07-30 13:19:22 +04:00
|
|
|
#include "creds/abstractcredentials.h"
|
2012-05-21 18:48:49 +04:00
|
|
|
|
2012-12-06 19:24:53 +04:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#include <windows.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2013-04-04 19:14:38 +04:00
|
|
|
#include <assert.h>
|
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
#include <QDebug>
|
2013-01-14 15:13:29 +04:00
|
|
|
#include <QSslSocket>
|
2012-02-15 12:30:37 +04:00
|
|
|
#include <QDir>
|
|
|
|
#include <QMutexLocker>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QTextStream>
|
2012-02-28 19:49:13 +04:00
|
|
|
#include <QTime>
|
2012-08-26 13:47:45 +04:00
|
|
|
#include <QApplication>
|
2012-12-11 15:49:48 +04:00
|
|
|
#include <QUrl>
|
2012-12-13 22:52:07 +04:00
|
|
|
#include <QSslCertificate>
|
2012-08-26 13:47:45 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
namespace Mirall {
|
|
|
|
|
2013-09-24 17:56:03 +04:00
|
|
|
void csyncLogCatcher(int /*verbosity*/,
|
|
|
|
const char */*function*/,
|
|
|
|
const char *buffer,
|
|
|
|
void */*userdata*/)
|
|
|
|
{
|
|
|
|
Logger::instance()->csyncLog( QString::fromUtf8(buffer) );
|
|
|
|
}
|
2012-08-02 12:17:15 +04:00
|
|
|
|
2013-09-24 17:56:03 +04:00
|
|
|
/* static variables to hold the credentials */
|
2013-04-15 17:55:54 +04:00
|
|
|
QMutex CSyncThread::_syncMutex;
|
2012-03-21 21:03:49 +04:00
|
|
|
|
2013-10-03 22:00:58 +04:00
|
|
|
CSyncThread::CSyncThread(CSYNC *csync, const QString &localPath, const QString &remotePath, SyncJournalDb *journal)
|
2014-01-07 18:42:21 +04:00
|
|
|
:_previousIndex(-1)
|
2012-02-15 12:30:37 +04:00
|
|
|
{
|
2013-05-03 21:11:00 +04:00
|
|
|
_localPath = localPath;
|
|
|
|
_remotePath = remotePath;
|
2013-04-20 14:15:27 +04:00
|
|
|
_csync_ctx = csync;
|
2013-10-03 22:00:58 +04:00
|
|
|
_journal = journal;
|
2013-05-16 15:54:22 +04:00
|
|
|
qRegisterMetaType<SyncFileItem>("SyncFileItem");
|
2013-10-28 13:47:10 +04:00
|
|
|
qRegisterMetaType<SyncFileItem::Status>("SyncFileItem::Status");
|
2012-02-15 12:30:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
CSyncThread::~CSyncThread()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-19 20:17:32 +04:00
|
|
|
//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
|
2013-08-21 17:29:04 +04:00
|
|
|
QString CSyncThread::csyncErrorToString(CSYNC_STATUS err)
|
2012-12-20 19:45:56 +04:00
|
|
|
{
|
|
|
|
QString errStr;
|
|
|
|
|
|
|
|
switch( err ) {
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_OK:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("Success.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_NO_LOCK:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed to create a lock file.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_STATEDB_LOAD_ERROR:
|
2014-02-04 14:08:18 +04:00
|
|
|
errStr = tr("CSync failed to load or create the journal file. "
|
|
|
|
"Make sure you have read and write permissions in the local sync directory.");
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_STATEDB_WRITE_ERROR:
|
2014-02-04 14:08:18 +04:00
|
|
|
errStr = tr("CSync failed to write the journal file.");
|
2013-08-19 18:15:20 +04:00
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_NO_MODULE:
|
2013-02-21 15:21:42 +04:00
|
|
|
errStr = tr("<p>The %1 plugin for csync could not be loaded.<br/>Please verify the installation!</p>").arg(Theme::instance()->appNameGUI());
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_TIMESKEW:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("The system time on this client is different than the system time on the server. "
|
|
|
|
"Please use a time synchronization service (NTP) on the server and client machines "
|
|
|
|
"so that the times remain the same.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_FILESYSTEM_UNKNOWN:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync could not detect the filesystem type.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_TREE_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync got an error while processing internal trees.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_MEMORY_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed to reserve memory.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_PARAM_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync fatal parameter error.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_UPDATE_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync processing step update failed.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_RECONCILE_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync processing step reconcile failed.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_PROPAGATE_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync processing step propagate failed.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_REMOTE_ACCESS_ERROR:
|
2013-04-20 14:15:27 +04:00
|
|
|
errStr = tr("<p>The target directory does not exist.</p><p>Please check the sync setup.</p>");
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_REMOTE_CREATE_ERROR:
|
|
|
|
case CSYNC_STATUS_REMOTE_STAT_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("A remote file can not be written. Please check the remote access.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_LOCAL_CREATE_ERROR:
|
|
|
|
case CSYNC_STATUS_LOCAL_STAT_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("The local filesystem can not be written. Please check permissions.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_PROXY_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed to connect through a proxy.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_PROXY_AUTH_ERROR:
|
|
|
|
errStr = tr("CSync could not authenticate at the proxy.");
|
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_LOOKUP_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed to lookup proxy or server.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_SERVER_AUTH_ERROR:
|
2013-02-21 15:21:42 +04:00
|
|
|
errStr = tr("CSync failed to authenticate at the %1 server.").arg(Theme::instance()->appNameGUI());
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_CONNECT_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed to connect to the network.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_TIMEOUT:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("A network connection timeout happend.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_HTTP_ERROR:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("A HTTP transmission error happened.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_PERMISSION_DENIED:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync failed due to not handled permission deniend.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_NOT_FOUND:
|
2013-11-25 21:22:41 +04:00
|
|
|
errStr = tr("CSync failed to access "); // filename gets added.
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_FILE_EXISTS:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync tried to create a directory that already exists.");
|
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_OUT_OF_SPACE:
|
2013-02-21 15:21:42 +04:00
|
|
|
errStr = tr("CSync: No space on %1 server available.").arg(Theme::instance()->appNameGUI());
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_QUOTA_EXCEEDED:
|
|
|
|
errStr = tr("CSync: No space on %1 server available.").arg(Theme::instance()->appNameGUI());
|
2012-12-20 19:45:56 +04:00
|
|
|
break;
|
2013-08-19 18:15:20 +04:00
|
|
|
case CSYNC_STATUS_UNSUCCESSFUL:
|
2012-12-20 19:45:56 +04:00
|
|
|
errStr = tr("CSync unspecified error.");
|
2013-10-02 21:41:17 +04:00
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_ABORTED:
|
|
|
|
errStr = tr("Aborted by the user");
|
|
|
|
break;
|
2012-12-20 19:45:56 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
errStr = tr("An internal error number %1 happend.").arg( (int) err );
|
|
|
|
}
|
|
|
|
|
|
|
|
return errStr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-11-20 16:44:01 +04:00
|
|
|
bool CSyncThread::checkBlacklisting( SyncFileItem *item )
|
|
|
|
{
|
|
|
|
bool re = false;
|
|
|
|
|
|
|
|
if( !_journal ) {
|
|
|
|
qWarning() << "Journal is undefined!";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SyncJournalBlacklistRecord entry = _journal->blacklistEntry(item->_file);
|
|
|
|
item->_blacklistedInDb = false;
|
|
|
|
|
|
|
|
// if there is a valid entry in the blacklist table and the retry count is
|
|
|
|
// already null or smaller than 0, the file is blacklisted.
|
|
|
|
if( entry.isValid() ) {
|
2013-11-29 19:15:26 +04:00
|
|
|
item->_blacklistedInDb = true;
|
|
|
|
|
2013-11-20 16:44:01 +04:00
|
|
|
if( entry._retryCount <= 0 ) {
|
|
|
|
re = true;
|
|
|
|
}
|
|
|
|
|
2013-11-29 19:15:26 +04:00
|
|
|
// if the retryCount is 0, but the etag for downloads or the mtime for uploads
|
|
|
|
// has changed, it is tried again
|
2013-11-20 16:44:01 +04:00
|
|
|
// note that if the retryCount is -1 we never try again.
|
|
|
|
if( entry._retryCount == 0 ) {
|
2013-11-29 19:15:26 +04:00
|
|
|
if( item->_dir == SyncFileItem::Up ) { // check the modtime
|
|
|
|
if(item->_modtime == 0 || entry._lastTryModtime == 0) {
|
2013-11-20 16:44:01 +04:00
|
|
|
re = false;
|
2013-11-29 19:15:26 +04:00
|
|
|
} else {
|
|
|
|
if( item->_modtime != entry._lastTryModtime ) {
|
|
|
|
re = false;
|
|
|
|
qDebug() << item->_file << " is blacklisted, but has changed mtime!";
|
|
|
|
}
|
2013-11-20 16:44:01 +04:00
|
|
|
}
|
|
|
|
} else {
|
2013-11-29 19:15:26 +04:00
|
|
|
// download, check the etag.
|
|
|
|
if( item->_etag.isEmpty() || entry._lastTryEtag.isEmpty() ) {
|
|
|
|
qDebug() << item->_file << "one ETag is empty, no blacklisting";
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
if( item->_etag != entry._lastTryEtag ) {
|
|
|
|
re = false;
|
|
|
|
qDebug() << item->_file << " is blacklisted, but has changed etag!";
|
|
|
|
}
|
2013-11-20 16:44:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-29 19:15:26 +04:00
|
|
|
|
2013-11-20 16:44:01 +04:00
|
|
|
if( re ) {
|
|
|
|
qDebug() << "Item is on blacklist: " << entry._file << "retries:" << entry._retryCount;
|
|
|
|
item->_instruction = CSYNC_INSTRUCTION_IGNORE;
|
2013-12-12 15:21:24 +04:00
|
|
|
// FIXME: put the error string into an .arg(..) later
|
|
|
|
item->_errorString = tr("The item is not synced because of previous errors:")
|
|
|
|
+ QLatin1String(" ")+ entry._errorString;
|
2013-11-26 15:22:28 +04:00
|
|
|
slotProgress( Progress::SoftError, *item );
|
2013-11-20 16:44:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
int CSyncThread::treewalkLocal( TREE_WALK_FILE* file, void *data )
|
|
|
|
{
|
|
|
|
return static_cast<CSyncThread*>(data)->treewalkFile( file, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
int CSyncThread::treewalkRemote( TREE_WALK_FILE* file, void *data )
|
|
|
|
{
|
|
|
|
return static_cast<CSyncThread*>(data)->treewalkFile( file, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
int CSyncThread::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
|
|
|
{
|
|
|
|
if( ! file ) return -1;
|
|
|
|
SyncFileItem item;
|
|
|
|
item._file = QString::fromUtf8( file->path );
|
2013-11-05 20:48:51 +04:00
|
|
|
item._originalFile = item._file;
|
2013-01-15 23:41:52 +04:00
|
|
|
item._instruction = file->instruction;
|
|
|
|
item._dir = SyncFileItem::None;
|
2013-10-25 15:28:48 +04:00
|
|
|
item._fileId = QString::fromUtf8(file->file_id);
|
2013-09-04 18:33:06 +04:00
|
|
|
|
2013-11-20 16:44:01 +04:00
|
|
|
// record the seen files to be able to clean the journal later
|
2013-11-11 14:11:45 +04:00
|
|
|
_seenFiles[item._file] = QString();
|
|
|
|
|
2013-12-04 15:19:38 +04:00
|
|
|
switch(file->error_status) {
|
|
|
|
case CSYNC_STATUS_OK:
|
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_INDIVIDUAL_IS_SYMLINK:
|
|
|
|
item._errorString = tr("Symbolic links are not supported in syncing.");
|
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_INDIVIDUAL_IGNORE_LIST:
|
|
|
|
item._errorString = tr("File is listed on the ignore list.");
|
|
|
|
break;
|
|
|
|
case CSYNC_STATUS_INDIVIDUAL_IS_INVALID_CHARS:
|
|
|
|
item._errorString = tr("File contains invalid characters that can not be synced cross platform.");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT("Non handled error-status");
|
|
|
|
/* No error string */
|
2013-09-02 19:25:07 +04:00
|
|
|
}
|
2013-09-04 18:33:06 +04:00
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
item._isDirectory = file->type == CSYNC_FTW_TYPE_DIR;
|
|
|
|
item._modtime = file->modtime;
|
2013-11-13 17:28:15 +04:00
|
|
|
item._etag = file->etag;
|
2013-09-11 10:49:09 +04:00
|
|
|
item._size = file->size;
|
2013-11-15 16:53:18 +04:00
|
|
|
item._should_update_etag = file->should_update_etag;
|
2013-12-06 17:11:51 +04:00
|
|
|
switch( file->type ) {
|
|
|
|
case CSYNC_FTW_TYPE_DIR:
|
|
|
|
item._type = SyncFileItem::Directory;
|
|
|
|
break;
|
|
|
|
case CSYNC_FTW_TYPE_FILE:
|
|
|
|
item._type = SyncFileItem::File;
|
|
|
|
break;
|
|
|
|
case CSYNC_FTW_TYPE_SLINK:
|
|
|
|
item._type = SyncFileItem::SoftLink;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
item._type = SyncFileItem::UnknownType;
|
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
|
|
|
|
SyncFileItem::Direction dir;
|
|
|
|
|
|
|
|
int re = 0;
|
|
|
|
|
2013-02-14 19:25:00 +04:00
|
|
|
switch(file->instruction) {
|
|
|
|
case CSYNC_INSTRUCTION_NONE:
|
|
|
|
break;
|
2013-09-11 10:42:29 +04:00
|
|
|
case CSYNC_INSTRUCTION_NEW:
|
|
|
|
case CSYNC_INSTRUCTION_SYNC:
|
|
|
|
case CSYNC_INSTRUCTION_CONFLICT:
|
2013-11-27 19:48:10 +04:00
|
|
|
case CSYNC_INSTRUCTION_RENAME:
|
|
|
|
case CSYNC_INSTRUCTION_REMOVE:
|
2013-09-11 10:42:29 +04:00
|
|
|
_progressInfo.overall_file_count++;
|
|
|
|
_progressInfo.overall_transmission_size += file->size;
|
|
|
|
//fall trough
|
2013-02-14 19:25:00 +04:00
|
|
|
default:
|
2013-09-11 10:42:29 +04:00
|
|
|
_needsUpdate = true;
|
2013-02-14 19:25:00 +04:00
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
switch(file->instruction) {
|
2013-10-29 15:05:31 +04:00
|
|
|
case CSYNC_INSTRUCTION_UPDATED:
|
|
|
|
// We need to update the database.
|
|
|
|
_journal->setFileRecord(SyncJournalFileRecord(item, _localPath + item._file));
|
|
|
|
item._instruction = CSYNC_INSTRUCTION_NONE;
|
|
|
|
// fall trough
|
2013-01-15 23:41:52 +04:00
|
|
|
case CSYNC_INSTRUCTION_NONE:
|
2013-10-03 22:00:58 +04:00
|
|
|
if (item._isDirectory && remote) {
|
|
|
|
// Because we want still to update etags of directories
|
|
|
|
dir = SyncFileItem::None;
|
|
|
|
} else {
|
|
|
|
// No need to do anything.
|
2013-12-06 19:37:01 +04:00
|
|
|
_hasFiles = true;
|
|
|
|
|
2013-10-03 22:00:58 +04:00
|
|
|
return re;
|
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
break;
|
|
|
|
case CSYNC_INSTRUCTION_RENAME:
|
|
|
|
dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
|
|
|
|
item._renameTarget = QString::fromUtf8( file->rename_path );
|
2013-05-15 17:22:20 +04:00
|
|
|
if (item._isDirectory)
|
|
|
|
_renamedFolders.insert(item._file, item._renameTarget);
|
2013-01-15 23:41:52 +04:00
|
|
|
break;
|
|
|
|
case CSYNC_INSTRUCTION_REMOVE:
|
|
|
|
dir = !remote ? SyncFileItem::Down : SyncFileItem::Up;
|
2013-11-27 19:48:10 +04:00
|
|
|
break;
|
2013-01-15 23:41:52 +04:00
|
|
|
case CSYNC_INSTRUCTION_CONFLICT:
|
|
|
|
case CSYNC_INSTRUCTION_IGNORE:
|
|
|
|
case CSYNC_INSTRUCTION_ERROR:
|
2013-11-25 19:16:33 +04:00
|
|
|
//
|
2013-11-26 15:22:28 +04:00
|
|
|
slotProgress(Progress::SoftError, item, 0, 0);
|
2013-01-15 23:41:52 +04:00
|
|
|
dir = SyncFileItem::None;
|
|
|
|
break;
|
|
|
|
case CSYNC_INSTRUCTION_EVAL:
|
|
|
|
case CSYNC_INSTRUCTION_NEW:
|
|
|
|
case CSYNC_INSTRUCTION_SYNC:
|
|
|
|
case CSYNC_INSTRUCTION_STAT_ERROR:
|
|
|
|
case CSYNC_INSTRUCTION_DELETED:
|
|
|
|
default:
|
|
|
|
dir = remote ? SyncFileItem::Down : SyncFileItem::Up;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
item._dir = dir;
|
2013-11-29 19:15:26 +04:00
|
|
|
// check for blacklisting of this item.
|
|
|
|
// if the item is on blacklist, the instruction was set to IGNORE
|
|
|
|
checkBlacklisting( &item );
|
|
|
|
|
|
|
|
if (file->instruction != CSYNC_INSTRUCTION_IGNORE
|
|
|
|
&& file->instruction != CSYNC_INSTRUCTION_REMOVE) {
|
|
|
|
_hasFiles = true;
|
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
_syncedItems.append(item);
|
|
|
|
|
|
|
|
return re;
|
|
|
|
}
|
|
|
|
|
2013-02-15 22:29:27 +04:00
|
|
|
void CSyncThread::handleSyncError(CSYNC *ctx, const char *state) {
|
2013-11-25 01:21:29 +04:00
|
|
|
CSYNC_STATUS err = csync_get_status( ctx );
|
2013-08-19 18:15:20 +04:00
|
|
|
const char *errMsg = csync_get_status_string( ctx );
|
2013-08-21 17:29:04 +04:00
|
|
|
QString errStr = csyncErrorToString(err);
|
2013-05-05 13:41:31 +04:00
|
|
|
if( errMsg ) {
|
2013-11-25 21:22:41 +04:00
|
|
|
if( !errStr.endsWith(" ")) {
|
|
|
|
errStr.append(" ");
|
|
|
|
}
|
2013-05-05 13:41:31 +04:00
|
|
|
errStr += QString::fromUtf8(errMsg);
|
|
|
|
}
|
2013-11-25 21:22:41 +04:00
|
|
|
|
|
|
|
// if there is csyncs url modifier in the error message, replace it.
|
|
|
|
if( errStr.contains("ownclouds://") ) errStr.replace("ownclouds://", "https://");
|
|
|
|
if( errStr.contains("owncloud://") ) errStr.replace("owncloud://", "http://");
|
|
|
|
|
2013-02-15 22:29:27 +04:00
|
|
|
qDebug() << " #### ERROR during "<< state << ": " << errStr;
|
2013-08-19 18:15:20 +04:00
|
|
|
|
2013-11-25 01:21:29 +04:00
|
|
|
if( CSYNC_STATUS_IS_EQUAL( err, CSYNC_STATUS_ABORTED) ) {
|
|
|
|
qDebug() << "Update phase was aborted by user!";
|
|
|
|
} else if( CSYNC_STATUS_IS_EQUAL( err, CSYNC_STATUS_SERVICE_UNAVAILABLE ) ||
|
2013-08-19 18:15:20 +04:00
|
|
|
CSYNC_STATUS_IS_EQUAL( err, CSYNC_STATUS_CONNECT_ERROR )) {
|
2013-02-15 22:29:27 +04:00
|
|
|
emit csyncUnavailable();
|
2013-08-19 18:15:20 +04:00
|
|
|
} else {
|
2013-02-15 22:29:27 +04:00
|
|
|
emit csyncError(errStr);
|
|
|
|
}
|
2013-10-04 17:13:36 +04:00
|
|
|
csync_commit(_csync_ctx);
|
|
|
|
emit finished();
|
|
|
|
_syncMutex.unlock();
|
|
|
|
thread()->quit();
|
2013-02-15 22:29:27 +04:00
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2012-08-26 13:47:45 +04:00
|
|
|
void CSyncThread::startSync()
|
2012-02-15 12:30:37 +04:00
|
|
|
{
|
2013-04-15 17:55:54 +04:00
|
|
|
if (!_syncMutex.tryLock()) {
|
|
|
|
qDebug() << Q_FUNC_INFO << "WARNING: Another sync seems to be running. Not starting a new one.";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
if( ! _csync_ctx ) {
|
|
|
|
qDebug() << "XXXXXXXXXXXXXXXX FAIL: do not have csync_ctx!";
|
|
|
|
}
|
2013-04-04 19:14:38 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << "Sync started";
|
|
|
|
|
2013-10-03 15:41:15 +04:00
|
|
|
|
2012-08-26 13:47:45 +04:00
|
|
|
qDebug() << "starting to sync " << qApp->thread() << QThread::currentThread();
|
2013-05-07 19:47:29 +04:00
|
|
|
_syncedItems.clear();
|
2013-02-14 19:25:00 +04:00
|
|
|
_needsUpdate = false;
|
2014-01-20 19:29:26 +04:00
|
|
|
|
|
|
|
_abortRequestedMutex.lock();
|
2013-10-03 15:41:15 +04:00
|
|
|
if (!_abortRequested.fetchAndAddRelease(0)) {
|
|
|
|
csync_resume(_csync_ctx);
|
|
|
|
}
|
2014-01-20 19:29:26 +04:00
|
|
|
_abortRequestedMutex.unlock();
|
2012-08-30 19:50:42 +04:00
|
|
|
|
2013-10-04 16:44:57 +04:00
|
|
|
if (!_journal->exists()) {
|
|
|
|
qDebug() << "=====sync looks new (no DB exists), activating recursive PROPFIND if csync supports it";
|
|
|
|
bool no_recursive_propfind = false;
|
|
|
|
csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
|
|
|
|
} else {
|
2013-11-18 12:58:02 +04:00
|
|
|
// retrieve the file count from the db and close it afterwards because
|
|
|
|
// csync_update also opens the database.
|
|
|
|
int fileRecordCount = 0;
|
|
|
|
fileRecordCount = _journal->getFileRecordCount();
|
|
|
|
_journal->close();
|
|
|
|
|
|
|
|
if( fileRecordCount == -1 ) {
|
|
|
|
qDebug() << "No way to create a sync journal!";
|
|
|
|
emit csyncError(tr("Unable to initialize a sync journal."));
|
|
|
|
|
|
|
|
csync_commit(_csync_ctx);
|
|
|
|
emit finished();
|
|
|
|
_syncMutex.unlock();
|
|
|
|
thread()->quit();
|
|
|
|
|
|
|
|
return;
|
|
|
|
// database creation error!
|
|
|
|
} else if ( fileRecordCount < 50 ) {
|
|
|
|
qDebug() << "=====sync DB has only" << fileRecordCount << "items, enable recursive PROPFIND if csync supports it";
|
|
|
|
bool no_recursive_propfind = false;
|
|
|
|
csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
|
|
|
|
} else {
|
|
|
|
qDebug() << "=====sync with existing DB";
|
|
|
|
}
|
2013-10-04 16:44:57 +04:00
|
|
|
}
|
2013-07-05 20:46:43 +04:00
|
|
|
|
2013-06-12 14:13:09 +04:00
|
|
|
csync_set_module_property(_csync_ctx, "csync_context", _csync_ctx);
|
2013-04-20 14:15:27 +04:00
|
|
|
csync_set_userdata(_csync_ctx, this);
|
2013-07-29 16:28:19 +04:00
|
|
|
// TODO: This should be a part of this method, but we don't have
|
|
|
|
// any way to get "session_key" module property from csync. Had we
|
|
|
|
// have it, then we could keep this code and remove it from
|
|
|
|
// AbstractCredentials implementations.
|
2013-10-30 19:31:47 +04:00
|
|
|
if (Account *account = AccountManager::instance()->account()) {
|
|
|
|
account->credentials()->syncContextPreStart(_csync_ctx);
|
|
|
|
} else {
|
|
|
|
qDebug() << Q_FUNC_INFO << "No default Account object, huh?";
|
|
|
|
}
|
2013-07-29 16:28:19 +04:00
|
|
|
// if (_lastAuthCookies.length() > 0) {
|
2013-07-29 16:44:54 +04:00
|
|
|
// // Stuff cookies inside csync, then we can avoid the intermediate HTTP 401 reply
|
2013-07-29 16:28:19 +04:00
|
|
|
// // when https://github.com/owncloud/core/pull/4042 is merged.
|
|
|
|
// QString cookiesAsString;
|
|
|
|
// foreach(QNetworkCookie c, _lastAuthCookies) {
|
|
|
|
// cookiesAsString += c.name();
|
|
|
|
// cookiesAsString += '=';
|
|
|
|
// cookiesAsString += c.value();
|
|
|
|
// cookiesAsString += "; ";
|
|
|
|
// }
|
|
|
|
// csync_set_module_property(_csync_ctx, "session_key", cookiesAsString.to
|
|
|
|
// }
|
2013-07-17 18:27:18 +04:00
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
// csync_set_auth_callback( _csync_ctx, getauth );
|
2013-09-24 17:56:03 +04:00
|
|
|
csync_set_log_callback( csyncLogCatcher );
|
|
|
|
csync_set_log_level( 11 );
|
2013-07-29 16:28:19 +04:00
|
|
|
|
2013-05-16 15:54:22 +04:00
|
|
|
_syncTime.start();
|
|
|
|
|
|
|
|
QElapsedTimer updateTime;
|
|
|
|
updateTime.start();
|
2012-08-09 16:13:20 +04:00
|
|
|
qDebug() << "#### Update start #################################################### >>";
|
2013-09-24 17:56:03 +04:00
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
if( csync_update(_csync_ctx) < 0 ) {
|
|
|
|
handleSyncError(_csync_ctx, "csync_update");
|
2013-02-15 22:29:27 +04:00
|
|
|
return;
|
2012-03-22 19:22:08 +04:00
|
|
|
}
|
2013-05-16 15:54:22 +04:00
|
|
|
qDebug() << "<<#### Update end #################################################### " << updateTime.elapsed();
|
2012-02-15 12:30:37 +04:00
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
if( csync_reconcile(_csync_ctx) < 0 ) {
|
2013-07-29 16:28:19 +04:00
|
|
|
handleSyncError(_csync_ctx, "csync_reconcile");
|
2013-02-15 22:29:27 +04:00
|
|
|
return;
|
2012-03-22 19:22:08 +04:00
|
|
|
}
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2013-11-25 19:16:33 +04:00
|
|
|
slotProgress(Progress::StartSync, SyncFileItem(), 0, 0);
|
|
|
|
|
2013-08-14 21:59:16 +04:00
|
|
|
_progressInfo = Progress::Info();
|
|
|
|
|
2013-06-08 17:40:45 +04:00
|
|
|
_hasFiles = false;
|
2013-02-20 20:26:07 +04:00
|
|
|
bool walkOk = true;
|
2013-11-11 14:11:45 +04:00
|
|
|
_seenFiles.clear();
|
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
if( csync_walk_local_tree(_csync_ctx, &treewalkLocal, 0) < 0 ) {
|
2013-02-15 22:29:27 +04:00
|
|
|
qDebug() << "Error in local treewalk.";
|
2013-02-20 20:26:07 +04:00
|
|
|
walkOk = false;
|
2013-01-15 23:41:52 +04:00
|
|
|
}
|
2013-04-20 14:15:27 +04:00
|
|
|
if( walkOk && csync_walk_remote_tree(_csync_ctx, &treewalkRemote, 0) < 0 ) {
|
2013-02-15 22:29:27 +04:00
|
|
|
qDebug() << "Error in remote treewalk.";
|
2013-01-15 23:41:52 +04:00
|
|
|
}
|
|
|
|
|
2013-05-15 17:22:20 +04:00
|
|
|
// Adjust the paths for the renames.
|
|
|
|
for (SyncFileItemVector::iterator it = _syncedItems.begin();
|
|
|
|
it != _syncedItems.end(); ++it) {
|
|
|
|
it->_file = adjustRenamedPath(it->_file);
|
|
|
|
}
|
|
|
|
|
2013-06-08 17:40:45 +04:00
|
|
|
if (!_hasFiles && !_syncedItems.isEmpty()) {
|
|
|
|
qDebug() << Q_FUNC_INFO << "All the files are going to be removed, asking the user";
|
2013-08-14 17:44:30 +04:00
|
|
|
bool cancel = false;
|
2013-06-10 17:57:23 +04:00
|
|
|
emit aboutToRemoveAllFiles(_syncedItems.first()._dir, &cancel);
|
2013-06-08 17:40:45 +04:00
|
|
|
if (cancel) {
|
|
|
|
qDebug() << Q_FUNC_INFO << "Abort sync";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 19:25:00 +04:00
|
|
|
if (_needsUpdate)
|
|
|
|
emit(started());
|
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
ne_session_s *session = 0;
|
|
|
|
// that call to set property actually is a get which will return the session
|
2013-11-05 20:53:01 +04:00
|
|
|
// FIXME add a csync_get_module_property to csync
|
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
csync_set_module_property(_csync_ctx, "get_dav_session", &session);
|
|
|
|
Q_ASSERT(session);
|
|
|
|
|
2013-10-02 21:41:17 +04:00
|
|
|
_propagator.reset(new OwncloudPropagator (session, _localPath, _remotePath,
|
2013-10-16 13:59:54 +04:00
|
|
|
_journal, &_abortRequested));
|
2013-10-04 17:13:36 +04:00
|
|
|
connect(_propagator.data(), SIGNAL(completed(SyncFileItem)),
|
|
|
|
this, SLOT(transferCompleted(SyncFileItem)), Qt::QueuedConnection);
|
2013-11-25 19:16:33 +04:00
|
|
|
connect(_propagator.data(), SIGNAL(progress(Progress::Kind,SyncFileItem,quint64,quint64)),
|
|
|
|
this, SLOT(slotProgress(Progress::Kind,SyncFileItem,quint64,quint64)));
|
2014-01-07 18:42:21 +04:00
|
|
|
connect(_propagator.data(), SIGNAL(progressChanged(qint64)), this, SLOT(slotProgressChanged(qint64)));
|
2013-10-28 13:47:10 +04:00
|
|
|
connect(_propagator.data(), SIGNAL(finished()), this, SLOT(slotFinished()));
|
2013-05-16 15:54:22 +04:00
|
|
|
|
2014-01-31 20:29:50 +04:00
|
|
|
setNetworkLimits();
|
|
|
|
|
|
|
|
_propagator->start(_syncedItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSyncThread::setNetworkLimits()
|
|
|
|
{
|
|
|
|
MirallConfigFile cfg;
|
|
|
|
|
|
|
|
if( !_propagator ) return;
|
|
|
|
|
2013-08-14 21:59:16 +04:00
|
|
|
int downloadLimit = 0;
|
|
|
|
if (cfg.useDownloadLimit()) {
|
|
|
|
downloadLimit = cfg.downloadLimit() * 1000;
|
|
|
|
}
|
|
|
|
_propagator->_downloadLimit = downloadLimit;
|
|
|
|
|
|
|
|
int uploadLimit = -75; // 75%
|
|
|
|
int useUpLimit = cfg.useUploadLimit();
|
|
|
|
if ( useUpLimit >= 1) {
|
|
|
|
uploadLimit = cfg.uploadLimit() * 1000;
|
|
|
|
} else if (useUpLimit == 0) {
|
|
|
|
uploadLimit = 0;
|
2012-02-28 19:49:13 +04:00
|
|
|
}
|
2013-08-14 21:59:16 +04:00
|
|
|
_propagator->_uploadLimit = uploadLimit;
|
|
|
|
|
2014-01-31 20:29:50 +04:00
|
|
|
qDebug() << " N------N Network Limits changed!";
|
|
|
|
|
2013-05-16 15:54:22 +04:00
|
|
|
}
|
2013-05-07 19:47:29 +04:00
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
void CSyncThread::transferCompleted(const SyncFileItem &item)
|
2013-05-16 15:54:22 +04:00
|
|
|
{
|
2013-10-04 17:55:10 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << item._file << item._status << item._errorString;
|
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
/* Update the _syncedItems vector */
|
2013-10-28 13:47:10 +04:00
|
|
|
int idx = _syncedItems.indexOf(item);
|
2013-10-04 17:13:36 +04:00
|
|
|
if (idx >= 0) {
|
|
|
|
_syncedItems[idx]._instruction = item._instruction;
|
|
|
|
_syncedItems[idx]._errorString = item._errorString;
|
|
|
|
_syncedItems[idx]._status = item._status;
|
2013-11-25 01:21:29 +04:00
|
|
|
|
|
|
|
} else {
|
|
|
|
qWarning() << Q_FUNC_INFO << "Could not find index in synced items!";
|
2013-10-04 17:13:36 +04:00
|
|
|
}
|
2013-05-16 15:54:22 +04:00
|
|
|
|
2013-10-28 13:47:10 +04:00
|
|
|
if (item._status == SyncFileItem::FatalError) {
|
2013-10-04 17:13:36 +04:00
|
|
|
emit csyncError(item._errorString);
|
|
|
|
}
|
2013-05-16 15:54:22 +04:00
|
|
|
}
|
2013-05-06 18:59:11 +04:00
|
|
|
|
2013-10-28 13:47:10 +04:00
|
|
|
void CSyncThread::slotFinished()
|
2013-05-16 15:54:22 +04:00
|
|
|
{
|
|
|
|
// emit the treewalk results.
|
2013-11-11 14:11:45 +04:00
|
|
|
if( ! _journal->postSyncCleanup( _seenFiles ) ) {
|
|
|
|
qDebug() << "Cleaning of synced ";
|
|
|
|
}
|
2013-11-21 14:13:58 +04:00
|
|
|
_journal->commit("All Finished.", false);
|
2013-10-03 22:00:58 +04:00
|
|
|
emit treeWalkResult(_syncedItems);
|
2013-05-16 15:54:22 +04:00
|
|
|
|
|
|
|
csync_commit(_csync_ctx);
|
|
|
|
|
|
|
|
qDebug() << "CSync run took " << _syncTime.elapsed() << " Milliseconds";
|
2013-11-25 19:16:33 +04:00
|
|
|
slotProgress(Progress::EndSync,SyncFileItem(), 0 , 0);
|
2013-05-16 15:54:22 +04:00
|
|
|
emit finished();
|
|
|
|
_propagator.reset(0);
|
|
|
|
_syncMutex.unlock();
|
2013-10-02 21:41:17 +04:00
|
|
|
thread()->quit();
|
2012-02-28 19:49:13 +04:00
|
|
|
}
|
|
|
|
|
2013-11-26 15:22:28 +04:00
|
|
|
void CSyncThread::progressProblem(Progress::Kind kind, const SyncFileItem& item)
|
2013-07-25 18:28:36 +04:00
|
|
|
{
|
2013-11-25 19:16:33 +04:00
|
|
|
Progress::SyncProblem problem;
|
2013-08-14 21:59:16 +04:00
|
|
|
|
2013-11-25 19:16:33 +04:00
|
|
|
problem.kind = kind;
|
|
|
|
problem.current_file = item._file;
|
|
|
|
problem.error_message = item._errorString;
|
|
|
|
problem.error_code = item._httpErrorCode;
|
|
|
|
problem.timestamp = QDateTime::currentDateTime();
|
|
|
|
|
|
|
|
// connected to something in folder.
|
|
|
|
emit transmissionProblem( problem );
|
|
|
|
}
|
|
|
|
|
2014-01-07 18:42:21 +04:00
|
|
|
void CSyncThread::slotProgressChanged(qint64 change)
|
|
|
|
{
|
|
|
|
_progressInfo.overall_transmission_size += change;
|
|
|
|
}
|
|
|
|
|
2013-11-25 19:16:33 +04:00
|
|
|
void CSyncThread::slotProgress(Progress::Kind kind, const SyncFileItem& item, quint64 curr, quint64 total)
|
|
|
|
{
|
2013-11-26 15:22:28 +04:00
|
|
|
if( Progress::isErrorKind(kind) ) {
|
|
|
|
progressProblem(kind, item);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-21 14:37:47 +04:00
|
|
|
if( kind == Progress::StartSync ) {
|
|
|
|
_currentFileNo = 0;
|
2013-11-27 19:48:10 +04:00
|
|
|
_lastOverallBytes = 0;
|
2013-11-21 14:37:47 +04:00
|
|
|
}
|
|
|
|
if( kind == Progress::StartDelete ||
|
|
|
|
kind == Progress::StartDownload ||
|
|
|
|
kind == Progress::StartRename ||
|
|
|
|
kind == Progress::StartUpload ) {
|
2014-01-07 18:42:21 +04:00
|
|
|
int indx = _syncedItems.indexOf(item);
|
|
|
|
if( _previousIndex != indx ) {
|
|
|
|
_currentFileNo += 1;
|
|
|
|
_previousIndex = indx;
|
|
|
|
}
|
2014-01-20 19:49:52 +04:00
|
|
|
curr = 0;
|
2013-11-21 14:37:47 +04:00
|
|
|
}
|
|
|
|
|
2013-11-27 19:48:10 +04:00
|
|
|
if( kind == Progress::EndUpload ||
|
2014-01-20 19:49:52 +04:00
|
|
|
kind == Progress::EndDownload) {
|
2013-11-27 19:48:10 +04:00
|
|
|
_lastOverallBytes += total;
|
|
|
|
}
|
2013-11-25 19:16:33 +04:00
|
|
|
|
2013-11-27 19:48:10 +04:00
|
|
|
Progress::Info pInfo(_progressInfo);
|
2013-08-14 21:59:16 +04:00
|
|
|
pInfo.kind = kind;
|
2013-11-25 19:16:33 +04:00
|
|
|
pInfo.current_file = item._file;
|
2013-12-06 18:07:25 +04:00
|
|
|
pInfo.rename_target = item._renameTarget;
|
2013-08-14 21:59:16 +04:00
|
|
|
pInfo.file_size = total;
|
|
|
|
pInfo.current_file_bytes = curr;
|
2013-11-21 14:37:47 +04:00
|
|
|
pInfo.current_file_no = _currentFileNo;
|
2013-11-27 19:48:10 +04:00
|
|
|
pInfo.timestamp = QDateTime::currentDateTime();
|
|
|
|
pInfo.overall_current_bytes = _lastOverallBytes + curr;
|
2013-07-26 15:44:38 +04:00
|
|
|
// Connect to something in folder!
|
2013-11-22 22:45:26 +04:00
|
|
|
emit transmissionProgress( pInfo );
|
2013-07-19 15:05:30 +04:00
|
|
|
}
|
|
|
|
|
2013-05-15 17:22:20 +04:00
|
|
|
/* Given a path on the remote, give the path as it is when the rename is done */
|
|
|
|
QString CSyncThread::adjustRenamedPath(const QString& original)
|
|
|
|
{
|
|
|
|
int slashPos = original.size();
|
|
|
|
while ((slashPos = original.lastIndexOf('/' , slashPos - 1)) > 0) {
|
|
|
|
QHash< QString, QString >::const_iterator it = _renamedFolders.constFind(original.left(slashPos));
|
|
|
|
if (it != _renamedFolders.constEnd()) {
|
|
|
|
return *it + original.mid(slashPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return original;
|
|
|
|
}
|
2013-10-02 21:41:17 +04:00
|
|
|
|
|
|
|
void CSyncThread::abort()
|
|
|
|
{
|
2014-01-20 19:29:26 +04:00
|
|
|
QMutexLocker locker(&_abortRequestedMutex);
|
2013-10-02 21:41:17 +04:00
|
|
|
csync_request_abort(_csync_ctx);
|
|
|
|
_abortRequested = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-29 16:28:19 +04:00
|
|
|
} // ns Mirall
|