diff --git a/bookinfodialog.cpp b/bookinfodialog.cpp index 9f0dc18..2083f7d 100644 --- a/bookinfodialog.cpp +++ b/bookinfodialog.cpp @@ -48,11 +48,9 @@ bookInfoDialog::bookInfoDialog(QWidget *parent) : global::library::isLatestBook = false; ui->bookTitleLabel->setText(global::library::bookTitle); - global::library::bookTitle = ""; } else { ui->bookTitleLabel->setText(global::library::bookTitle); - global::library::bookTitle = ""; QDir gutenbergDir; gutenbergDir.mkpath("/inkbox/gutenberg"); @@ -93,6 +91,7 @@ bookInfoDialog::~bookInfoDialog() void bookInfoDialog::on_closeBtn_clicked() { + global::library::bookTitle = ""; bookInfoDialog::close(); } @@ -102,6 +101,7 @@ void bookInfoDialog::on_getBtn_clicked() QDir gutenbergDir; gutenbergDir.mkpath("/inkbox/gutenberg"); string_writeconfig("/inkbox/gutenberg/bookid", QString::number(global::library::bookId).toStdString()); + string_writeconfig("/inkbox/gutenberg/booktitle", global::library::bookTitle.toStdString()); string_writeconfig("/opt/ibxd", "gutenberg_get_book\n"); global::toast::modalToast = true; diff --git a/librarywidget.cpp b/librarywidget.cpp index 7e1c76d..d4ef757 100644 --- a/librarywidget.cpp +++ b/librarywidget.cpp @@ -248,26 +248,30 @@ void libraryWidget::closeIndefiniteToast() { void libraryWidget::syncCatalog() { global::toast::modalToast = true; global::toast::indefiniteToast = true; + bool syncDone = false; showToast("Sync in progress"); string_writeconfig("/opt/ibxd", "gutenberg_sync\n"); QTimer * syncCheckTimer = new QTimer(this); syncCheckTimer->setInterval(100); connect(syncCheckTimer, &QTimer::timeout, [&]() { - if(QFile::exists("/inkbox/gutenbergSyncDone") == true) { - if(checkconfig("/inkbox/gutenbergSyncDone") == true) { - qDebug() << "Gutenberg sync successfully completed"; - toastWindow->close(); - setupView(); + if(syncDone == false) { + if(QFile::exists("/inkbox/gutenbergSyncDone") == true) { + if(checkconfig("/inkbox/gutenbergSyncDone") == true) { + qDebug() << "Gutenberg sync successfully completed"; + toastWindow->close(); + setupView(); + } + else { + qDebug() << "Gutenberg sync encountered an error"; + toastWindow->close(); + showToast("Error"); + QFile::remove("/external_root/opt/storage/gutenberg/last_sync"); + QTimer::singleShot(5000, this, SLOT(close())); + } + QFile::remove("/inkbox/gutenbergSyncDone"); + syncDone = true; } - else { - qDebug() << "Gutenberg sync encountered an error"; - toastWindow->close(); - showToast("Error"); - QFile::remove("/external_root/opt/storage/gutenberg/last_sync"); - QTimer::singleShot(5000, this, SLOT(close())); - } - QFile::remove("/inkbox/gutenbergSyncDone"); } } ); syncCheckTimer->start(); diff --git a/mainwindow.cpp b/mainwindow.cpp index fe177d9..d9b030c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -502,6 +502,9 @@ MainWindow::MainWindow(QWidget *parent) updatemsg = updatemsg.append(checkconfig_str_val); QMessageBox::information(this, tr("Information"), updatemsg); string_writeconfig("/external_root/opt/update/inkbox_updated", "false"); + if(QFile::exists("/external_root/opt/storage/gutenberg/last_sync")) { + QFile::remove("/external_root/opt/storage/gutenberg/last_sync"); + } } }