Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Konsole
Commits
59cf70d4
Commit
59cf70d4
authored
Mar 01, 2022
by
Ömer Fadıl Usta
😊
Browse files
Check first if ssh config file exist or not
parent
d72a7475
Pipeline
#144379
passed with stage
in 2 minutes and 1 second
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/plugins/SSHManager/sshmanagermodel.cpp
View file @
59cf70d4
...
...
@@ -16,6 +16,7 @@
#include
<QDebug>
#include
<QFile>
#include
<QFileInfo>
#include
<QLoggingCategory>
#include
<QStandardPaths>
#include
<QTextStream>
...
...
@@ -34,7 +35,7 @@ Q_LOGGING_CATEGORY(SshManagerPlugin, "org.kde.konsole.plugin.sshmanager")
namespace
{
const
QString
S
shDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
HomeLocation
)
+
QStringLiteral
(
"/.ssh/"
);
const
QString
s
shDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
HomeLocation
)
+
QStringLiteral
(
"/.ssh/"
);
}
SSHManagerModel
::
SSHManagerModel
(
QObject
*
parent
)
...
...
@@ -48,12 +49,13 @@ SSHManagerModel::SSHManagerModel(QObject *parent)
if
(
invisibleRootItem
()
->
rowCount
()
==
0
)
{
addTopLevelItem
(
i18n
(
"Default"
));
}
m_sshConfigWatcher
.
addPath
(
SshDir
+
QStringLiteral
(
"config"
));
connect
(
&
m_sshConfigWatcher
,
&
QFileSystemWatcher
::
fileChanged
,
this
,
[
this
]
{
if
(
QFileInfo
::
exists
(
sshDir
+
QStringLiteral
(
"config"
))){
m_sshConfigWatcher
.
addPath
(
sshDir
+
QStringLiteral
(
"config"
));
connect
(
&
m_sshConfigWatcher
,
&
QFileSystemWatcher
::
fileChanged
,
this
,
[
this
]
{
startImportFromSshConfig
();
});
startImportFromSshConfig
();
});
startImportFromSshConfig
();
}
}
SSHManagerModel
::~
SSHManagerModel
()
noexcept
...
...
@@ -308,7 +310,7 @@ void SSHManagerModel::removeIndex(const QModelIndex &idx)
void
SSHManagerModel
::
startImportFromSshConfig
()
{
importFromSshConfigFile
(
S
shDir
+
QStringLiteral
(
"config"
));
importFromSshConfigFile
(
s
shDir
+
QStringLiteral
(
"config"
));
}
void
SSHManagerModel
::
importFromSshConfigFile
(
const
QString
&
file
)
...
...
@@ -342,7 +344,7 @@ void SSHManagerModel::importFromSshConfigFile(const QString &file)
continue
;
}
importFromSshConfigFile
(
S
shDir
+
lists
.
at
(
1
));
importFromSshConfigFile
(
s
shDir
+
lists
.
at
(
1
));
continue
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment