From 9c7ee6ef85fbc11234b2f0bf903c9a647f4b395b Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Mon, 23 Oct 2017 10:46:41 +0200 Subject: Reconcile: Rename handling fixes: duplicate file ids When users share the same tree several times (say A/ and A/B/ are both shared) the remote tree can have several entries that have the same file id. This needs to be respected in rename detection. Also adds several tests and fixes for issues noticed during testing. See #6096 --- test/syncenginetestutils.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'test/syncenginetestutils.h') diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 376b47496..e6d4a395e 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -161,12 +161,15 @@ public: FileInfo(const QString &name, qint64 size) : name{name}, isDir{false}, size{size} { } FileInfo(const QString &name, qint64 size, char contentChar) : name{name}, isDir{false}, size{size}, contentChar{contentChar} { } FileInfo(const QString &name, const std::initializer_list &children) : name{name} { - QString p = path(); - for (const auto &source : children) { - auto &dest = this->children[source.name] = source; - dest.parentPath = p; - dest.fixupParentPathRecursively(); - } + for (const auto &source : children) + addChild(source); + } + + void addChild(const FileInfo &info) + { + auto &dest = this->children[info.name] = info; + dest.parentPath = path(); + dest.fixupParentPathRecursively(); } void remove(const QString &relativePath) override { @@ -952,6 +955,11 @@ private: } else { QFile f{diskChild.filePath()}; f.open(QFile::ReadOnly); + auto content = f.read(1); + if (content.size() == 0) { + qWarning() << "Empty file at:" << diskChild.filePath(); + continue; + } char contentChar = f.read(1).at(0); templateFi.children.insert(diskChild.fileName(), FileInfo{diskChild.fileName(), diskChild.size(), contentChar}); } -- cgit v1.2.3