mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-03 05:57:40 -05:00
impr: Handle provider opening more centrally, switch to existing provider if same file is being opened again
This commit is contained in:
@@ -15,7 +15,7 @@ namespace hex::plugin::remote {
|
||||
bool isResizable() const override { return false; }
|
||||
bool isSavable() const override { return isWritable(); }
|
||||
|
||||
bool open() override;
|
||||
OpenResult open() override;
|
||||
void close() override;
|
||||
void save() override;
|
||||
|
||||
|
||||
@@ -7,5 +7,6 @@
|
||||
"hex.plugin.remote.ssh_provider.key_file": "Private Key Path",
|
||||
"hex.plugin.remote.ssh_provider.passphrase": "Passphrase",
|
||||
"hex.plugin.remote.ssh_provider.connect": "Connect",
|
||||
"hex.plugin.remote.ssh_provider.ssh_access": "Access file using raw SSH"
|
||||
"hex.plugin.remote.ssh_provider.ssh_access": "Access file using raw SSH",
|
||||
"hex.plugin.remote.ssh_provider.error.open_failed": "Failed to open remote 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() {
|
||||
|
||||
Reference in New Issue
Block a user