From 6ceb45bac4efc2ebd6ad3bc427efb9552105ce1c Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Dec 2021 12:41:33 +0100 Subject: [PATCH 1/2] test files that should be renamed in sub-directory Signed-off-by: Matthieu Gallien --- test/testlocaldiscovery.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/testlocaldiscovery.cpp b/test/testlocaldiscovery.cpp index 1933993328..15e4898dfd 100644 --- a/test/testlocaldiscovery.cpp +++ b/test/testlocaldiscovery.cpp @@ -212,10 +212,16 @@ private slots: const QString fileWithSpaces1(" foo"); const QString fileWithSpaces2(" bar "); const QString fileWithSpaces3("bla "); + const QString fileWithSpaces4("A/ foo"); + const QString fileWithSpaces5("A/ bar "); + const QString fileWithSpaces6("A/bla "); fakeFolder.localModifier().insert(fileWithSpaces1); fakeFolder.localModifier().insert(fileWithSpaces2); fakeFolder.localModifier().insert(fileWithSpaces3); + fakeFolder.localModifier().insert(fileWithSpaces4); + fakeFolder.localModifier().insert(fileWithSpaces5); + fakeFolder.localModifier().insert(fileWithSpaces6); QVERIFY(fakeFolder.syncOnce()); @@ -233,6 +239,21 @@ private slots: QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces3)); QVERIFY(fakeFolder.currentLocalState().find(fileWithSpaces3.trimmed())); QVERIFY(!fakeFolder.currentLocalState().find(fileWithSpaces3)); + + QVERIFY(fakeFolder.currentRemoteState().find("A/foo")); + QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces4)); + QVERIFY(fakeFolder.currentLocalState().find("A/foo")); + QVERIFY(!fakeFolder.currentLocalState().find(fileWithSpaces4)); + + QVERIFY(fakeFolder.currentRemoteState().find("A/bar")); + QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces5)); + QVERIFY(fakeFolder.currentLocalState().find("A/bar")); + QVERIFY(!fakeFolder.currentLocalState().find(fileWithSpaces5)); + + QVERIFY(fakeFolder.currentRemoteState().find("A/bla")); + QVERIFY(!fakeFolder.currentRemoteState().find(fileWithSpaces6)); + QVERIFY(fakeFolder.currentLocalState().find("A/bla")); + QVERIFY(!fakeFolder.currentLocalState().find(fileWithSpaces6)); } void testCreateFileWithTrailingSpaces_localTrimmedDoesExist_dontRenameAndUploadFile() From b053cf9e2a987a3d554a2b047a60c2f8dfb9a716 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Dec 2021 11:43:45 +0100 Subject: [PATCH 2/2] do not forget the path when renaming files with invalid names Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 8d16c6f0a8..f67967025c 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -389,7 +389,13 @@ void ProcessDirectoryJob::processFile(PathTuple path, item->_originalFile = path._original; item->_previousSize = dbEntry._fileSize; item->_previousModtime = dbEntry._modtime; - item->_renameTarget = localEntry.renameName; + if (!localEntry.renameName.isEmpty()) { + if (_dirItem) { + item->_renameTarget = _dirItem->_file + "/" + localEntry.renameName; + } else { + item->_renameTarget = localEntry.renameName; + } + } if (dbEntry._modtime == localEntry.modtime && dbEntry._type == ItemTypeVirtualFile && localEntry.type == ItemTypeFile) { item->_type = ItemTypeFile;