Skip to content

Commit 54fbe65

Browse files
committed
[sftp] Fix output format strings.
Forced by changes in libfmt.
1 parent 3957d3a commit 54fbe65

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Diff for: src/ssh/sftp_client.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ bool SFTPClient::push_dir(const fs::path& source_path, const fs::path& target_pa
188188
{
189189
if (sftp_mkdir(sftp.get(), remote_file_path.u8string().c_str(), 0777) != SSH_OK &&
190190
sftp_get_error(sftp.get()) != SSH_FX_FILE_ALREADY_EXISTS)
191-
throw SFTPError{"cannot create remote directory {}: {}", remote_file_path,
191+
throw SFTPError{"cannot create remote directory \"{}\": {}",
192+
remote_file_path,
192193
ssh_get_error(sftp->session)};
193194

194195
subdirectory_perms.emplace_back(remote_file_path, status.permissions());
@@ -202,13 +203,14 @@ bool SFTPClient::push_dir(const fs::path& source_path, const fs::path& target_pa
202203

203204
auto remote_file_info = mp_sftp_lstat(sftp.get(), remote_file_path.u8string().c_str());
204205
if (remote_file_info && remote_file_info->type == SSH_FILEXFER_TYPE_DIRECTORY)
205-
throw SFTPError{"cannot overwrite remote directory {} with non-directory", remote_file_path};
206+
throw SFTPError{"cannot overwrite remote directory \"{}\" with non-directory", remote_file_path};
206207

207208
if ((sftp_unlink(sftp.get(), remote_file_path.u8string().c_str()) != SSH_FX_OK &&
208209
sftp_get_error(sftp.get()) != SSH_FX_NO_SUCH_FILE) ||
209210
sftp_symlink(sftp.get(), link_target.u8string().c_str(), remote_file_path.u8string().c_str()) !=
210211
SSH_FX_OK)
211-
throw SFTPError{"cannot create remote symlink {}: {}", remote_file_path,
212+
throw SFTPError{"cannot create remote symlink \"{}\": {}",
213+
remote_file_path,
212214
ssh_get_error(sftp->session)};
213215
break;
214216
}
@@ -228,9 +230,11 @@ bool SFTPClient::push_dir(const fs::path& source_path, const fs::path& target_pa
228230
const auto& [path, perms] = *it;
229231
if (sftp_chmod(sftp.get(), path.u8string().c_str(), static_cast<mode_t>(perms)) != SSH_FX_OK)
230232
{
231-
mpl::log(
232-
mpl::Level::error, log_category,
233-
fmt::format("cannot set permissions for remote directory {}: {}", path, ssh_get_error(sftp->session)));
233+
mpl::log(mpl::Level::error,
234+
log_category,
235+
fmt::format("cannot set permissions for remote directory \"{}\": {}",
236+
path,
237+
ssh_get_error(sftp->session)));
234238
success = false;
235239
}
236240
}

Diff for: src/ssh/sftp_utils.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fs::path SFTPUtils::get_remote_file_target(sftp_session sftp, const fs::path& so
7979
target_full_path += source_path.filename().u8string().insert(0, "/");
8080
target_attr = mp_sftp_stat(sftp, target_full_path.u8string().c_str());
8181
if (target_attr && target_attr->type == SSH_FILEXFER_TYPE_DIRECTORY)
82-
throw SFTPError{"cannot overwrite remote directory {} with non-directory", target_full_path};
82+
throw SFTPError{"cannot overwrite remote directory \"{}\" with non-directory", target_full_path};
8383

8484
return target_full_path;
8585
}
@@ -121,25 +121,25 @@ fs::path SFTPUtils::get_remote_dir_target(sftp_session sftp, const fs::path& sou
121121
auto target_info = mp_sftp_stat(sftp, target_path_string.c_str());
122122

123123
if (target_info && target_info->type != SSH_FILEXFER_TYPE_DIRECTORY)
124-
throw SFTPError{"cannot overwrite remote non-directory {} with directory", target_path};
124+
throw SFTPError{"cannot overwrite remote non-directory \"{}\" with directory", target_path};
125125

126126
if (!target_info)
127127
{
128128
if (make_parent)
129129
mkdir_recursive(sftp, target_path);
130130
else if (sftp_mkdir(sftp, target_path_string.c_str(), 0777) != SSH_FX_OK)
131-
throw SFTPError{"cannot create remote directory {}: {}", target_path, ssh_get_error(sftp->session)};
131+
throw SFTPError{"cannot create remote directory \"{}\": {}", target_path, ssh_get_error(sftp->session)};
132132
return target_path;
133133
}
134134

135135
fs::path child_path = target_path_string + '/' + source_path.filename().u8string();
136136
auto child_path_string = child_path.u8string();
137137
auto child_info = mp_sftp_stat(sftp, child_path_string.c_str());
138138
if (child_info && child_info->type != SSH_FILEXFER_TYPE_DIRECTORY)
139-
throw SFTPError{"cannot overwrite remote non-directory {} with directory", child_path};
139+
throw SFTPError{"cannot overwrite remote non-directory \"{}\" with directory", child_path};
140140

141141
if (!child_info && sftp_mkdir(sftp, child_path_string.c_str(), 0777) != SSH_FX_OK)
142-
throw SFTPError{"cannot create remote directory {}: {}", child_path, ssh_get_error(sftp->session)};
142+
throw SFTPError{"cannot create remote directory \"{}\": {}", child_path, ssh_get_error(sftp->session)};
143143

144144
return child_path;
145145
}
@@ -154,9 +154,9 @@ void SFTPUtils::mkdir_recursive(sftp_session sftp, const fs::path& path)
154154
for (const auto& partial_path : partial_paths)
155155
if (auto attr = mp_sftp_lstat(sftp, partial_path.u8string().c_str());
156156
attr && attr->type != SSH_FILEXFER_TYPE_DIRECTORY)
157-
throw SFTPError{"cannot overwrite remote non-directory {} with directory", partial_path};
157+
throw SFTPError{"cannot overwrite remote non-directory \"{}\" with directory", partial_path};
158158
else if (!attr && sftp_mkdir(sftp, partial_path.u8string().c_str(), 0777) != SSH_FX_OK)
159-
throw SFTPError{"cannot create remote directory {}: {}", partial_path, ssh_get_error(sftp->session)};
159+
throw SFTPError{"cannot create remote directory \"{}\": {}", partial_path, ssh_get_error(sftp->session)};
160160
}
161161

162162
std::unique_ptr<SFTPClient> SFTPUtils::make_SFTPClient(const std::string& host, int port, const std::string& username,

0 commit comments

Comments
 (0)