Compare commits

..

No commits in common. "10d43282b6b645ff5d2a641d7119763d630e5388" and "0e26020d13a7f47c2d22f28c85bf492899336189" have entirely different histories.

View File

@ -823,9 +823,9 @@ bool PackageConf::set_package_confs(QSqlDatabase& p_db) {
}
void PackageConf::sync(QSqlDatabase& p_db) {
bool task_succeeded = true;
int attempt = 0;
while (!task_succeeded) {
bool oneshot = true;
while (oneshot) {
oneshot = false;
try {
QSqlQuery query(p_db);
@ -850,13 +850,8 @@ void PackageConf::sync(QSqlDatabase& p_db) {
query.addBindValue(branch->id);
query.addBindValue(release->id);
attempt++;
task_succeeded = query.exec();
if (!task_succeeded) {
if (query.lastError().text().contains("database is locked")) {
int delay = 1000 * static_cast<int>(std::pow(2, attempt - 1));
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
} else task_succeeded = true;
if (!query.exec()) {
qDebug() << "Failed to sync PackageConf:" << query.lastError().text();
}
} catch (...) {}
}
@ -1233,7 +1228,6 @@ std::set<std::shared_ptr<Task>> Task::get_completed_tasks(QSqlDatabase& p_db, st
void Task::save(QSqlDatabase& p_db, int _packageconf_id) {
bool task_succeeded = false;
int attempt = 0;
while (!task_succeeded) {
QSqlQuery query(p_db);
query.prepare("UPDATE task SET jobstatus_id = ?, queue_time = ?, start_time = ?, finish_time = ?, successful = ?, log = ? WHERE id = ?");
@ -1245,13 +1239,7 @@ void Task::save(QSqlDatabase& p_db, int _packageconf_id) {
query.addBindValue(QString::fromStdString(std::regex_replace(log->get(), std::regex(R"(^\s+)"), "")));
query.addBindValue(id);
task_succeeded = query.exec();
attempt++;
if (!task_succeeded) {
if (query.lastError().text().contains("database is locked")) {
int delay = 1000 * static_cast<int>(std::pow(2, attempt - 1));
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
} else task_succeeded = true;
}
if (!task_succeeded) qDebug() << "Failed to save task to database, retrying:" << query.lastError().text();
}
QSqlQuery link_query(p_db);