From 505dba5b23a110d5ef91885c31d45676585a56f8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 12 May 2015 16:32:00 +0200 Subject: [PATCH 1/7] csync walk tree: Try to find the 'other_node' in the source directory in case of renames This fixes t2.pl --- csync/src/csync.c | 14 ++++++++++++++ csync/src/csync_rename.cc | 16 ++++++++++++++++ csync/src/csync_rename.h | 3 +++ 3 files changed, 33 insertions(+) diff --git a/csync/src/csync.c b/csync/src/csync.c index 65a0655afc..5f720797c3 100644 --- a/csync/src/csync.c +++ b/csync/src/csync.c @@ -386,6 +386,20 @@ static int _csync_treewalk_visitor(void *obj, void *data) { SAFE_FREE(renamed_path); } + if (!other_node) { + /* Check the source path as well. */ + int len; + uint64_t h = 0; + char *renamed_path = csync_rename_adjust_path_source(ctx, cur->path); + + if (!c_streq(renamed_path, cur->path)) { + len = strlen( renamed_path ); + h = c_jhash64((uint8_t *) renamed_path, len, 0); + other_node = c_rbtree_find(other_tree, &h); + } + SAFE_FREE(renamed_path); + } + if (obj == NULL || data == NULL) { ctx->status_code = CSYNC_STATUS_PARAM_ERROR; return -1; diff --git a/csync/src/csync_rename.cc b/csync/src/csync_rename.cc index 64da49aa73..f7c77a4ea2 100644 --- a/csync/src/csync_rename.cc +++ b/csync/src/csync_rename.cc @@ -43,6 +43,7 @@ struct csync_rename_s { } std::map folder_renamed_to; // map from->to + std::map folder_renamed_from; // map to->from struct renameop { csync_file_stat_t *st; @@ -63,6 +64,7 @@ void csync_rename_destroy(CSYNC* ctx) void csync_rename_record(CSYNC* ctx, const char* from, const char* to) { csync_rename_s::get(ctx)->folder_renamed_to[from] = to; + csync_rename_s::get(ctx)->folder_renamed_from[to] = from; } char* csync_rename_adjust_path(CSYNC* ctx, const char* path) @@ -78,4 +80,18 @@ char* csync_rename_adjust_path(CSYNC* ctx, const char* path) return c_strdup(path); } +char* csync_rename_adjust_path_source(CSYNC* ctx, const char* path) +{ + csync_rename_s* d = csync_rename_s::get(ctx); + for (std::string p = _parentDir(path); !p.empty(); p = _parentDir(p)) { + std::map< std::string, std::string >::iterator it = d->folder_renamed_from.find(p); + if (it != d->folder_renamed_from.end()) { + std::string rep = it->second + (path + p.length()); + return c_strdup(rep.c_str()); + } + } + return c_strdup(path); +} + + } diff --git a/csync/src/csync_rename.h b/csync/src/csync_rename.h index 75247696c2..a4f50a0ac5 100644 --- a/csync/src/csync_rename.h +++ b/csync/src/csync_rename.h @@ -26,7 +26,10 @@ extern "C" { #endif +/* Return the final destination path of a given patch in case of renames */ char *csync_rename_adjust_path(CSYNC *ctx, const char *path); +/* Return the source of a given path in case of renames */ +char *csync_rename_adjust_path_source(CSYNC *ctx, const char *path); void csync_rename_destroy(CSYNC *ctx); void csync_rename_record(CSYNC *ctx, const char *from, const char *to); From c2dacd03a53807fe7c25592a9aae14b52334ffaf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 12 May 2015 16:35:27 +0200 Subject: [PATCH 2/7] BandwidthManager: fix warnings Unused variables --- src/libsync/bandwidthmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsync/bandwidthmanager.cpp b/src/libsync/bandwidthmanager.cpp index 3a10b0d732..ae48aed219 100644 --- a/src/libsync/bandwidthmanager.cpp +++ b/src/libsync/bandwidthmanager.cpp @@ -184,7 +184,7 @@ void BandwidthManager::relativeUploadMeasuringTimerExpired() // qDebug() << Q_FUNC_INFO << _relativeUploadLimitProgressAtMeasuringRestart // << relativeLimitProgressMeasured << relativeLimitProgressDifference; - qint64 speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec*1000.0) / 1024.0; +// qint64 speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec*1000.0) / 1024.0; // qDebug() << Q_FUNC_INFO << relativeLimitProgressDifference/1024 <<"kB =>" << speedkBPerSec << "kB/sec on full speed (" // << _relativeLimitCurrentMeasuredDevice->_readWithProgress << _relativeLimitCurrentMeasuredDevice->_read // << qAbs(_relativeLimitCurrentMeasuredDevice->_readWithProgress @@ -277,7 +277,7 @@ void BandwidthManager::relativeDownloadMeasuringTimerExpired() qDebug() << Q_FUNC_INFO << _relativeDownloadLimitProgressAtMeasuringRestart << relativeLimitProgressMeasured << relativeLimitProgressDifference; - qint64 speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec*1000.0) / 1024.0; +// qint64 speedkBPerSec = (relativeLimitProgressDifference / relativeLimitMeasuringTimerIntervalMsec*1000.0) / 1024.0; // qDebug() << Q_FUNC_INFO << relativeLimitProgressDifference/1024 <<"kB =>" << speedkBPerSec << "kB/sec on full speed (" // << _relativeLimitCurrentMeasuredJob->currentDownloadPosition() ; From 6b16e18eb864f0d4b1bdc78546ad642b33dd4d61 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 12 May 2015 16:26:04 +0200 Subject: [PATCH 3/7] tx.pl: Use HTTP Keep-Alive --- csync/tests/ownCloud/ownCloud/Test.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm index a4fb6bdff7..6e755b054c 100644 --- a/csync/tests/ownCloud/ownCloud/Test.pm +++ b/csync/tests/ownCloud/ownCloud/Test.pm @@ -124,7 +124,8 @@ sub initTesting(;$) $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 } - $d = HTTP::DAV->new(); + my $ua = HTTP::DAV::UserAgent->new(keep_alive => 1 ); + $d = HTTP::DAV->new(-useragent => $ua); $d->credentials( -url=> $owncloud, -realm=>"ownCloud", -user=> $user, From cdfafa2180bc44ced078afabde57995a2d4f03c6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 12 May 2015 17:10:53 +0200 Subject: [PATCH 4/7] Propagator: Mention name of conflict file (for debugging) --- src/libsync/propagatedownload.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index a0337488bc..65fc409a74 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -532,6 +532,7 @@ void PropagateDownloadFileQNAM::downloadFinished() done(SyncFileItem::SoftError, renameError); return; } + qDebug() << "Created conflict file" << fn << "->" << conflictFileName; } FileSystem::setModTime(_tmpFile.fileName(), _item._modtime); From dd5a49bc7881d0bdb1259f14070320237aeb9cd5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 12 May 2015 17:25:45 +0200 Subject: [PATCH 5/7] Application: Disable to workaround of QLockFile bug for Qt versions that are fixed --- src/gui/application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/application.cpp b/src/gui/application.cpp index c23609b702..0e4eaa0edb 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -110,9 +110,9 @@ Application::Application(int &argc, char **argv) : if (isRunning()) return; -#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) && QT_VERSION < QT_VERSION_CHECK(5, 4, 2) // Workaround for QTBUG-44576: Make sure a stale QSettings lock file - // is deleted. + // is deleted. (Introduced in Qt 5.4.0 and fixed in Qt 5.4.2) { QString lockFilePath = ConfigFile().configFile() + QLatin1String(".lock"); QLockFile(lockFilePath).removeStaleLockFile(); From 76166c62527cf313909d8c7c93e7557ee7a5fbe0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 12 May 2015 17:52:12 +0200 Subject: [PATCH 6/7] SyncEngine: Fix comment A comment should descibe the code, and not a patch. --- src/libsync/syncengine.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 29be34ac5e..cfae321977 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -608,13 +608,14 @@ void SyncEngine::startSync() bool isUpdateFrom_1_8 = _journal->isUpdateFrom_1_8_0(); /* - * If 1.8.0 caused missing data in the local tree, this patch gets it - * back. For that, the usage of the journal for remote repository is - * disabled at the first start. + * If we are upgrading from a client version older than 1.5 is found, + * we cannot read from the database because we need to fetch the files id and etags. + * + * If 1.8.0 caused missing data in the local tree, so we also don't read from DB + * to get back the files that were gone. */ if (fileRecordCount >= 1 && (isUpdateFrom_1_5 || isUpdateFrom_1_8)) { - qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5; - // Disable the read from DB to be sure to re-read all the fileid and etags. + qDebug() << "detected update from 1.5 or 1.8" << fileRecordCount << isUpdateFrom_1_5; _csync_ctx->read_remote_from_db = false; } else { _csync_ctx->read_remote_from_db = true; From bcc896fb6e301d38242cef158f50cdaedd1e0ebd Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 12 May 2015 22:55:54 +0200 Subject: [PATCH 7/7] Qt4: Fix test --- test/testxmlparse.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/testxmlparse.h b/test/testxmlparse.h index 0b667eb507..167cb159a1 100644 --- a/test/testxmlparse.h +++ b/test/testxmlparse.h @@ -431,14 +431,14 @@ private slots: this, SLOT(slotFinishedSuccessfully()) ); QHash sizes; - QVERIFY(parser.parse( testXml, &sizes, "/ä" )); + QVERIFY(parser.parse( testXml, &sizes, QString::fromUtf8("/ä") )); QVERIFY(_success); - QVERIFY(_items.contains("/ä/ä.pdf")); - QVERIFY(_items.contains("/ä")); + QVERIFY(_items.contains(QString::fromUtf8("/ä/ä.pdf"))); + QVERIFY(_items.contains(QString::fromUtf8("/ä"))); QVERIFY(_items.size() == 2 ); - QVERIFY(_subdirs.contains("/ä")); + QVERIFY(_subdirs.contains(QString::fromUtf8("/ä"))); QVERIFY(_subdirs.size() == 1); }