Compare commits
2 Commits
495912f0d2
...
296f37262d
Author | SHA1 | Date | |
---|---|---|---|
296f37262d | |||
8b6ff0a865 |
@ -1146,27 +1146,27 @@ std::string CiLogic::queue_pull_tarball(std::vector<std::shared_ptr<PackageConf>
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Task> tarball_task = std::make_shared<Task>();
|
||||||
task_queue->enqueue(
|
task_queue->enqueue(
|
||||||
job_statuses.at("pull"),
|
job_statuses.at("pull"),
|
||||||
[this](std::shared_ptr<Log> log) mutable {
|
[this, r, &task_queue, tarball_task, job_statuses](std::shared_ptr<Log> log) mutable {
|
||||||
std::shared_ptr<PackageConf> pkgconf = log->get_task_context()->get_parent_packageconf();
|
std::shared_ptr<PackageConf> pkgconf = log->get_task_context()->get_parent_packageconf();
|
||||||
bool pull_ok = pull_project(pkgconf, log);
|
if (pull_project(pkgconf, log)) {
|
||||||
|
task_queue->enqueue(
|
||||||
|
job_statuses.at("tarball"),
|
||||||
|
[this, r](std::shared_ptr<Log> log) mutable {
|
||||||
|
bool tarball_ok = create_project_tarball(r, log);
|
||||||
|
},
|
||||||
|
r
|
||||||
|
);
|
||||||
|
tarball_task = r->get_task_by_jobstatus(job_statuses.at("tarball"));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
r
|
r
|
||||||
);
|
);
|
||||||
|
|
||||||
new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses.at("pull"));
|
new_item->first_pull_task = r->get_task_by_jobstatus(job_statuses.at("pull"));
|
||||||
|
new_item->first_tarball_task = tarball_task;
|
||||||
task_queue->enqueue(
|
|
||||||
job_statuses.at("tarball"),
|
|
||||||
[this](std::shared_ptr<Log> log) mutable {
|
|
||||||
std::shared_ptr<PackageConf> pkgconf = log->get_task_context()->get_parent_packageconf();
|
|
||||||
bool tarball_ok = create_project_tarball(pkgconf, log);
|
|
||||||
},
|
|
||||||
r
|
|
||||||
);
|
|
||||||
|
|
||||||
new_item->first_tarball_task = r->get_task_by_jobstatus(job_statuses.at("tarball"));
|
|
||||||
new_item->first_pkgconf = r;
|
new_item->first_pkgconf = r;
|
||||||
|
|
||||||
new_item->packaging_commit = r->packaging_commit;
|
new_item->packaging_commit = r->packaging_commit;
|
||||||
|
@ -56,11 +56,13 @@ QSqlDatabase get_thread_connection() {
|
|||||||
return thread_db;
|
return thread_db;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ci_query_exec(QSqlQuery* query) {
|
bool ci_query_exec(QSqlQuery* query, const QString query_string) {
|
||||||
bool passed = false;
|
bool passed = false;
|
||||||
int attempt = 0;
|
int attempt = 0;
|
||||||
while (!passed) {
|
while (!passed) {
|
||||||
passed = query->exec();
|
if (query_string.isEmpty()) passed = query->exec();
|
||||||
|
else passed = query->exec(query_string);
|
||||||
|
|
||||||
if (passed) return true;
|
if (passed) return true;
|
||||||
attempt++;
|
attempt++;
|
||||||
|
|
||||||
@ -79,9 +81,9 @@ bool init_database(const QString& database_path) {
|
|||||||
// Apply PRAGMAs
|
// Apply PRAGMAs
|
||||||
{
|
{
|
||||||
QSqlQuery pragma_query(get_thread_connection());
|
QSqlQuery pragma_query(get_thread_connection());
|
||||||
pragma_query.exec("PRAGMA journal_mode = WAL;");
|
ci_query_exec(&pragma_query, "PRAGMA journal_mode = WAL;");
|
||||||
pragma_query.exec("PRAGMA synchronous = NORMAL;");
|
ci_query_exec(&pragma_query, "PRAGMA synchronous = NORMAL;");
|
||||||
pragma_query.exec("PRAGMA foreign_keys = ON;");
|
ci_query_exec(&pragma_query, "PRAGMA foreign_keys = ON;");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the schema creation (or migration) statements
|
// Run the schema creation (or migration) statements
|
||||||
@ -200,7 +202,7 @@ bool init_database(const QString& database_path) {
|
|||||||
for (const QString &statement : sql_statements) {
|
for (const QString &statement : sql_statements) {
|
||||||
QSqlQuery query(get_thread_connection());
|
QSqlQuery query(get_thread_connection());
|
||||||
QString trimmed = statement.trimmed();
|
QString trimmed = statement.trimmed();
|
||||||
if (!trimmed.isEmpty() && !query.exec(trimmed)) {
|
if (!trimmed.isEmpty() && !ci_query_exec(&query, trimmed)) {
|
||||||
qDebug() << "Failed to execute SQL: " << trimmed
|
qDebug() << "Failed to execute SQL: " << trimmed
|
||||||
<< "\nError: " << query.lastError().text();
|
<< "\nError: " << query.lastError().text();
|
||||||
return false;
|
return false;
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
|
|
||||||
#include <QSqlDatabase>
|
#include <QSqlDatabase>
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
QSqlDatabase get_thread_connection();
|
QSqlDatabase get_thread_connection();
|
||||||
bool ci_query_exec(QSqlQuery* query);
|
bool ci_query_exec(QSqlQuery* query, const QString query_string = "");
|
||||||
bool init_database(const QString& database_path);
|
bool init_database(const QString& database_path);
|
||||||
|
|
||||||
#endif // DB_COMMON_H
|
#endif // DB_COMMON_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user