diff --git a/src/model/file_info.cpp b/src/model/file_info.cpp index 8b3ed045..4337c2b1 100644 --- a/src/model/file_info.cpp +++ b/src/model/file_info.cpp @@ -320,6 +320,7 @@ bool file_info_t::is_partly_available() const noexcept { return missing_blocks < const std::filesystem::path &file_info_t::get_path() const noexcept { if (!path) { path = folder_info->get_folder()->get_path() / boost::nowide::widen(name); + path->make_preferred(); } return path.value(); } diff --git a/tests/053-scan_task.cpp b/tests/053-scan_task.cpp index db44eb7f..adad8a1c 100644 --- a/tests/053-scan_task.cpp +++ b/tests/053-scan_task.cpp @@ -807,6 +807,8 @@ SECTION("regular files") { CHECK(seen.count("some")); CHECK(seen.count("some/a.txt")); } + bfs::permissions(parent, bfs::perms::all, ec); + bfs::permissions(path, bfs::perms::all, ec); } } diff --git a/tests/071-fs_actor.cpp b/tests/071-fs_actor.cpp index c2ddb1f2..1ff08ff8 100644 --- a/tests/071-fs_actor.cpp +++ b/tests/071-fs_actor.cpp @@ -89,7 +89,7 @@ struct fixture_t { file_addr = file_actor->get_address(); auto builder = diff_builder_t(*cluster); - builder.upsert_folder(folder_id, root_path.string(), "my-label") + builder.upsert_folder(folder_id, root_path, "my-label") .apply(*sup) .update_peer(peer_device->device_id(), "some_name", "some-cn", true) .apply(*sup) @@ -193,8 +193,8 @@ void test_remote_copy() { auto file = folder_my->get_file_infos().by_name(proto::get_name(pr_fi)); - auto& path = file->get_path(); - auto tmp_path = path.parent_path() / (path.filename().wstring() + L".syncspirit-tmp"); + auto &path = file->get_path(); + auto tmp_path = path.parent_path() / (path.filename().wstring() + L".syncspirit-tmp"); REQUIRE(bfs::exists(tmp_path)); REQUIRE(bfs::file_size(tmp_path) == 5); } @@ -216,7 +216,7 @@ void test_remote_copy() { SECTION("existing file") { bfs::path target = root_path / "content"; proto::set_type(pr_fi, proto::FileInfoType::SYMLINK); - proto::set_symlink_target(pr_fi, target.string()); + proto::set_symlink_target(pr_fi, boost::nowide::narrow(target.wstring())); write_file(target, "zzz"); @@ -234,7 +234,7 @@ void test_remote_copy() { SECTION("non-existing file") { bfs::path target = root_path / "non-existing-content"; proto::set_type(pr_fi, proto::FileInfoType::SYMLINK); - proto::set_symlink_target(pr_fi, target.string()); + proto::set_symlink_target(pr_fi, boost::nowide::narrow(target.wstring())); auto peer_file = make_file(); builder.remote_copy(*peer_file).apply(*sup); @@ -250,12 +250,24 @@ void test_remote_copy() { } SECTION("deleted file") { + auto name = bfs::path(L"папка") / L"файл.bin"; + pr_fi = {}; + proto::set_name(pr_fi, boost::nowide::narrow(name.generic_wstring())); + proto::set_modified_s(pr_fi, modified); + proto::set_sequence(pr_fi, folder_peer->get_max_sequence() + 1); proto::set_deleted(pr_fi, true); - bfs::path target = root_path / proto::get_name(pr_fi); + + auto &v = proto::get_version(pr_fi); + proto::add_counters(v, proto::Counter(peer_device->device_id().get_uint(), 1)); + + bfs::path target = root_path / name; + bfs::create_directories(target.parent_path()); write_file(target, "zzz"); REQUIRE(bfs::exists(target)); auto peer_file = make_file(); + CHECK(peer_file->get_path() == target); + REQUIRE(bfs::exists(peer_file->get_path())); builder.remote_copy(*peer_file).apply(*sup); auto file = folder_my->get_file_infos().by_name(proto::get_name(pr_fi)); diff --git a/tests/086-scan_actor.cpp b/tests/086-scan_actor.cpp index 0d6223fb..44d237f4 100644 --- a/tests/086-scan_actor.cpp +++ b/tests/086-scan_actor.cpp @@ -877,9 +877,9 @@ void test_races() { auto file_peer = fi_peer->get_file_infos().by_name("a.bin"); SECTION("non-finished/flushed new file") { auto file_opt = fs::file_t::open_write(file_peer); - CHECK(file_opt); + REQUIRE(file_opt); // CHECK(file_opt.assume_error().message() == "zzz"); - auto& file = file_opt.assume_value(); + auto &file = file_opt.assume_value(); REQUIRE(bfs::exists(file.get_path())); auto file_ptr = fs::file_ptr_t(new fs::file_t(std::move(file))); rw_cache->put(file_ptr); diff --git a/tests/diff-builder.cpp b/tests/diff-builder.cpp index 5f383ed8..f42906d4 100644 --- a/tests/diff-builder.cpp +++ b/tests/diff-builder.cpp @@ -177,7 +177,7 @@ diff_builder_t &diff_builder_t::then() noexcept { return *this; } -diff_builder_t &diff_builder_t::upsert_folder(std::string_view id, const bfs::path& path, std::string_view label, +diff_builder_t &diff_builder_t::upsert_folder(std::string_view id, const bfs::path &path, std::string_view label, std::uint64_t index_id) noexcept { db::Folder db_folder; db::set_id(db_folder, id); diff --git a/tests/diff-builder.h b/tests/diff-builder.h index 86833729..c29f0b64 100644 --- a/tests/diff-builder.h +++ b/tests/diff-builder.h @@ -68,7 +68,7 @@ struct SYNCSPIRIT_TEST_API diff_builder_t : private model::diff::apply_controlle diff_builder_t &then() noexcept; index_maker_t make_index(utils::bytes_view_t sha256, std::string_view folder_id) noexcept; - diff_builder_t &upsert_folder(std::string_view id, const bfs::path& path, std::string_view label = "", + diff_builder_t &upsert_folder(std::string_view id, const bfs::path &path, std::string_view label = "", std::uint64_t index_id = 0) noexcept; diff_builder_t &upsert_folder(const db::Folder &data, std::uint64_t index_id = 0) noexcept; diff_builder_t &update_peer(const model::device_id_t &device, std::string_view name = "", diff --git a/tests/test-utils.cpp b/tests/test-utils.cpp index cf26b339..4c7c14c5 100644 --- a/tests/test-utils.cpp +++ b/tests/test-utils.cpp @@ -148,7 +148,7 @@ bfs::path unique_path() { std::transform(random_name.begin(), random_name.end(), random_name.begin(), [](unsigned char c) { return std::tolower(c); }); auto name = std::wstring(L"tmp-") + boost::nowide::widen(random_name); - return bfs::absolute(bfs::current_path() / bfs::path(name)); + return bfs::absolute(bfs::current_path() / bfs::path(name)); } utils::bytes_view_t as_bytes(std::string_view str) {