Skip to content

Commit

Permalink
Merge pull request #5971 from nextcloud/bugfix/fixFilenameEncodingTes…
Browse files Browse the repository at this point in the history
…tOnWindows

on windows file names can always be encoded: fix wrong test
  • Loading branch information
mgallien authored Aug 16, 2023
2 parents f990b23 + f90cb23 commit 4d650e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent
}

auto localCodec = QTextCodec::codecForLocale();
if (localCodec->mibEnum() != 106) {
if (!OCC::Utility::isWindows() && localCodec->mibEnum() != 106) {
// If the locale codec is not UTF-8, we must check that the filename from the server can
// be encoded in the local file system.
//
// (Note: on windows, the FS is always UTF-16, so we don't need to check) //
// We cannot use QTextCodec::canEncode() since that can incorrectly return true, see
// https://bugreports.qt.io/browse/QTBUG-6925.
QTextEncoder encoder(localCodec, QTextCodec::ConvertInvalidToNull);
Expand Down
9 changes: 9 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,15 @@ private slots:
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(spy.count(), 1);
}

void testFileDownloadWithUnicodeCharacterInName() {
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
ItemCompletedSpy completeSpy(fakeFolder);
fakeFolder.remoteModifier().insert("A/abcdęfg.txt");
fakeFolder.syncOnce();
QVERIFY(itemDidCompleteSuccessfully(completeSpy, "A/abcdęfg.txt"));
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
};

QTEST_GUILESS_MAIN(TestSyncEngine)
Expand Down

0 comments on commit 4d650e7

Please sign in to comment.