Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not forget the path when renaming files with invalid names #4033

Merged
merged 2 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

mgallien marked this conversation as resolved.
Show resolved Hide resolved
if (dbEntry._modtime == localEntry.modtime && dbEntry._type == ItemTypeVirtualFile && localEntry.type == ItemTypeFile) {
item->_type = ItemTypeFile;
Expand Down
21 changes: 21 additions & 0 deletions test/testlocaldiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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()
Expand Down