fix askpas dir
This commit is contained in:
@@ -50,6 +50,7 @@ void ProcessManager::set_status(Status s)
|
|||||||
void ProcessManager::finished(bool ok, QString reason)
|
void ProcessManager::finished(bool ok, QString reason)
|
||||||
{
|
{
|
||||||
qWarning() << ok << " " << reason;
|
qWarning() << ok << " " << reason;
|
||||||
|
m_askpass_dir.reset();
|
||||||
set_status(Status::Null);
|
set_status(Status::Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,21 +116,21 @@ std::expected<QString, QString> ProcessManager::check_askpas()
|
|||||||
|
|
||||||
QString ProcessManager::create_ask_pass_helper()
|
QString ProcessManager::create_ask_pass_helper()
|
||||||
{
|
{
|
||||||
auto askpass_dir = std::make_unique<QTemporaryDir>();
|
m_askpass_dir = std::make_unique<QTemporaryDir>();
|
||||||
if (!askpass_dir->isValid())
|
if (!m_askpass_dir->isValid())
|
||||||
{
|
{
|
||||||
qWarning() << "cannot create temporary dir for askpass";
|
qWarning() << "cannot create temporary dir for askpass";
|
||||||
askpass_dir.reset();
|
m_askpass_dir.reset();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile::setPermissions(askpass_dir->path(), QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner);
|
QFile::setPermissions(m_askpass_dir->path(), QFileDevice::ReadOwner | QFileDevice::WriteOwner | QFileDevice::ExeOwner);
|
||||||
const QString path = askpass_dir->filePath(QStringLiteral("askpass.sh"));
|
const QString path = m_askpass_dir->filePath(QStringLiteral("askpass.sh"));
|
||||||
QFile script(path);
|
QFile script(path);
|
||||||
if (!script.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
if (!script.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||||
{
|
{
|
||||||
qWarning() << "cannot write askpass helper:" << script.errorString();
|
qWarning() << "cannot write askpass helper:" << script.errorString();
|
||||||
askpass_dir.reset();
|
m_askpass_dir.reset();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class ProcessManager : public QObject
|
|||||||
QString m_password;
|
QString m_password;
|
||||||
QVariantList m_packages;
|
QVariantList m_packages;
|
||||||
int m_package_count = 0;
|
int m_package_count = 0;
|
||||||
|
std::unique_ptr<QTemporaryDir> m_askpass_dir;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void set_packages(const QVariantList& v);
|
void set_packages(const QVariantList& v);
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ void UpdateManager::on_process_finished(int exit_code, QProcess::ExitStatus stat
|
|||||||
add_log_line(m_package_manager + QStringLiteral(": ") + m_update_log_buffer);
|
add_log_line(m_package_manager + QStringLiteral(": ") + m_update_log_buffer);
|
||||||
|
|
||||||
m_update_log_buffer.clear();
|
m_update_log_buffer.clear();
|
||||||
m_askpass_dir.reset();
|
|
||||||
|
|
||||||
if (status != QProcess::CrashExit && exit_code == 0)
|
if (status != QProcess::CrashExit && exit_code == 0)
|
||||||
{
|
{
|
||||||
@@ -51,7 +50,6 @@ void UpdateManager::on_process_error(QProcess::ProcessError error)
|
|||||||
{
|
{
|
||||||
if (error != QProcess::FailedToStart) return;
|
if (error != QProcess::FailedToStart) return;
|
||||||
|
|
||||||
m_askpass_dir.reset();
|
|
||||||
qWarning().noquote() << "failed to start" << m_package_manager << ":" << m_process.errorString();
|
qWarning().noquote() << "failed to start" << m_package_manager << ":" << m_process.errorString();
|
||||||
add_log_line(m_package_manager + QStringLiteral(": failed to start: ") + m_process.errorString());
|
add_log_line(m_package_manager + QStringLiteral(": failed to start: ") + m_process.errorString());
|
||||||
m_update_log_buffer.clear();
|
m_update_log_buffer.clear();
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class UpdateManager : public QObject
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_package_manager = "yay";
|
QString m_package_manager = "yay";
|
||||||
std::unique_ptr<QTemporaryDir> m_askpass_dir;
|
|
||||||
QByteArray m_update_output;
|
QByteArray m_update_output;
|
||||||
QStringList m_update_log;
|
QStringList m_update_log;
|
||||||
bool m_update_timedout = false;
|
bool m_update_timedout = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user