From 8bc529be3dae2d0a515f55812c24ee669b4f34bf Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 15 Oct 2022 09:20:31 -0300 Subject: [PATCH 1/2] fix: include hidden files when copying instances fixes instance ccopy on linux .-. Signed-off-by: flow --- launcher/FileSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 5d179641..7ab32513 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -170,7 +170,7 @@ bool copy::operator()(const QString& offset) // blacklisted paths, so we iterate over the source directory, and if there's no blacklist // match, we copy the file. QDir src_dir(src); - QDirIterator source_it(src, QDir::Filter::Files, QDirIterator::Subdirectories); + QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories); while (source_it.hasNext()) { auto src_path = source_it.next(); From 82d7f9f5a46fe0d66aa907825cf784efc13f8792 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 15 Oct 2022 09:34:47 -0300 Subject: [PATCH 2/2] chore(tests): add test for FS copy with dot folders/files Signed-off-by: flow --- tests/FileSystem_test.cpp | 36 ++++++++++++++++++ .../.secret_folder/.secret_file.txt | Bin 0 -> 29 bytes 2 files changed, 36 insertions(+) create mode 100644 tests/testdata/FileSystem/test_folder/.secret_folder/.secret_file.txt diff --git a/tests/FileSystem_test.cpp b/tests/FileSystem_test.cpp index 4efb90ac..47a963b0 100644 --- a/tests/FileSystem_test.cpp +++ b/tests/FileSystem_test.cpp @@ -147,6 +147,42 @@ slots: f(); } + void test_copy_with_dot_hidden() + { + QString folder = QFINDTESTDATA("testdata/FileSystem/test_folder"); + auto f = [&folder]() + { + QTemporaryDir tempDir; + tempDir.setAutoRemove(true); + qDebug() << "From:" << folder << "To:" << tempDir.path(); + + QDir target_dir(FS::PathCombine(tempDir.path(), "test_folder")); + qDebug() << tempDir.path(); + qDebug() << target_dir.path(); + FS::copy c(folder, target_dir.path()); + c(); + + auto filter = QDir::Filter::Files | QDir::Filter::Dirs | QDir::Filter::Hidden; + + for (auto entry: target_dir.entryList(filter)) { + qDebug() << entry; + } + + QVERIFY(target_dir.entryList(filter).contains(".secret_folder")); + target_dir.cd(".secret_folder"); + QVERIFY(target_dir.entryList(filter).contains(".secret_file.txt")); + }; + + // first try variant without trailing / + QVERIFY(!folder.endsWith('/')); + f(); + + // then variant with trailing / + folder.append('/'); + QVERIFY(folder.endsWith('/')); + f(); + } + void test_getDesktop() { QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); diff --git a/tests/testdata/FileSystem/test_folder/.secret_folder/.secret_file.txt b/tests/testdata/FileSystem/test_folder/.secret_folder/.secret_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..65e37085f46700c2d2c1b21efb9c56f52802bb41 GIT binary patch literal 29 hcmd1L2LXlRg8cmKN`=(K;*!)Nh1B$P1*`mgE&!?n3Yh=^ literal 0 HcmV?d00001