impr: Handle provider opening more centrally, switch to existing provider if same file is being opened again

This commit is contained in:
WerWolv
2025-12-17 12:55:24 +01:00
parent c11c05a399
commit 89004574d3
48 changed files with 211 additions and 158 deletions

View File

@@ -11,7 +11,7 @@
namespace hex::plugin::remote {
bool SSHProvider::open() {
prv::Provider::OpenResult SSHProvider::open() {
if (!m_sftpClient.isConnected()) {
try {
if (m_authMethod == AuthMethod::Password) {
@@ -22,8 +22,7 @@ namespace hex::plugin::remote {
m_sftpClient = std::move(client);
}
} catch (const std::exception& e) {
setErrorMessage(e.what());
return false;
return OpenResult::failure(e.what());
}
}
@@ -33,11 +32,14 @@ namespace hex::plugin::remote {
else
m_remoteFile = m_sftpClient.openFileSFTP(m_remoteFilePath, SSHClient::OpenMode::ReadWrite);
} catch (const std::exception& e) {
setErrorMessage(e.what());
return false;
return OpenResult::failure(e.what());
}
return m_remoteFile->isOpen();
if (!m_remoteFile->isOpen()) {
return OpenResult::failure("hex.plugin.remote.ssh_provider.error.open_failed"_lang);
}
return {};
}
void SSHProvider::close() {