Skip to content

Commit

Permalink
Use utf8 conversion instead of wide string
Browse files Browse the repository at this point in the history
Sploder12 committed Dec 17, 2024
1 parent 34924ac commit a5015cd
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ssh/sftp_client.cpp
Original file line number Diff line number Diff line change
@@ -147,7 +147,7 @@ void SFTPClient::pull_file(const fs::path& source_path, const fs::path& target_p
do_pull_file(source_path, *local_file);

auto source_perms = mp_sftp_stat(sftp.get(), source_path.u8string().c_str())->permissions;
if (!MP_PLATFORM.set_permissions(QString::fromStdWString(target_path.wstring()), static_cast<Perms>(source_perms)))
if (!MP_PLATFORM.set_permissions(QString::fromStdString(target_path.u8string()), static_cast<Perms>(source_perms)))
throw SFTPError{"cannot set permissions for local file {}", target_path};

if (local_file->fail())
@@ -301,7 +301,7 @@ bool SFTPClient::pull_dir(const fs::path& source_path, const fs::path& target_pa
for (auto it = subdirectory_perms.crbegin(); it != subdirectory_perms.crend(); ++it)
{
const auto& [path, perms] = *it;
if (!MP_PLATFORM.set_permissions(QString::fromStdWString(path.wstring()), static_cast<Perms>(perms)))
if (!MP_PLATFORM.set_permissions(QString::fromStdString(path.u8string()), static_cast<Perms>(perms)))
{
mpl::log(mpl::Level::error,
log_category,
10 changes: 5 additions & 5 deletions tests/test_sftp_client.cpp
Original file line number Diff line number Diff line change
@@ -293,7 +293,7 @@ TEST_F(SFTPClient, pull_file_success)
REPLACE(sftp_stat, [&](auto...) { return get_dummy_sftp_attr(SSH_FILEXFER_TYPE_REGULAR, "", perms); });
mp::Perms written_perms;
EXPECT_CALL(mock_platform,
set_permissions(QString::fromStdWString(target_path.wstring()), static_cast<mp::Perms>(perms)))
set_permissions(QString::fromStdString(target_path.u8string()), static_cast<mp::Perms>(perms)))
.WillOnce([&](auto, auto perms) {
written_perms = perms;
return true;
@@ -361,7 +361,7 @@ TEST_F(SFTPClient, pull_file_cannot_write_target)
};
REPLACE(sftp_read, mocked_sftp_read);
REPLACE(sftp_stat, [&](auto...) { return get_dummy_sftp_attr(); });
EXPECT_CALL(mock_platform, set_permissions(QString::fromStdWString(target_path.wstring()), _))
EXPECT_CALL(mock_platform, set_permissions(QString::fromStdString(target_path.u8string()), _))
.WillOnce(Return(true));
REPLACE(sftp_setstat, [](auto...) { return SSH_FX_OK; });

@@ -402,7 +402,7 @@ TEST_F(SFTPClient, pull_file_cannot_set_perms)
REPLACE(sftp_stat, [&](auto...) { return get_dummy_sftp_attr(SSH_FILEXFER_TYPE_REGULAR, "", perms); });

EXPECT_CALL(mock_platform,
set_permissions(QString::fromStdWString(target_path.wstring()), static_cast<mp::Perms>(perms)))
set_permissions(QString::fromStdString(target_path.u8string()), static_cast<mp::Perms>(perms)))
.WillOnce(Return(false));

auto sftp_client = make_sftp_client();
@@ -751,13 +751,13 @@ TEST_F(SFTPClient, pull_dir_success_regular)
mp::Perms dir_written_perms;
EXPECT_CALL(
mock_platform,
set_permissions(QString::fromStdWString((target_path / "file").wstring()), static_cast<mp::Perms>(perms)))
set_permissions(QString::fromStdString((target_path / "file").u8string()), static_cast<mp::Perms>(perms)))
.WillOnce([&](auto, auto perms) {
file_written_perms = perms;
return true;
});
EXPECT_CALL(mock_platform,
set_permissions(QString::fromStdWString(target_path.wstring()), static_cast<mp::Perms>(perms)))
set_permissions(QString::fromStdString(target_path.u8string()), static_cast<mp::Perms>(perms)))
.WillOnce([&](auto, auto perms) {
dir_written_perms = perms;
return true;

0 comments on commit a5015cd

Please sign in to comment.