mirror of
https://github.com/Quill-OS/quill.git
synced 2024-10-31 21:33:22 -07:00
Finally fix online library hanging on sync
This commit is contained in:
parent
20b6f7231a
commit
9d69deee99
3 changed files with 12 additions and 9 deletions
|
@ -262,13 +262,13 @@ namespace {
|
|||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
config.close();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -282,13 +282,13 @@ namespace {
|
|||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
config.close();
|
||||
if(contentstr.find("true") != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
|
@ -485,6 +485,7 @@ namespace {
|
|||
QTextStream in (&config);
|
||||
const QString content = in.readAll();
|
||||
std::string contentstr = content.toStdString();
|
||||
config.close();
|
||||
|
||||
// Thanks to https://stackoverflow.com/questions/22516463/how-do-i-find-a-complete-word-not-part-of-it-in-a-string-in-c
|
||||
std::regex r("\\b" + pattern + "\\b");
|
||||
|
@ -496,7 +497,6 @@ namespace {
|
|||
else {
|
||||
return false;
|
||||
}
|
||||
config.close();
|
||||
return 0;
|
||||
};
|
||||
bool isBatteryLow() {
|
||||
|
|
|
@ -264,14 +264,15 @@ void libraryWidget::closeIndefiniteToast() {
|
|||
void libraryWidget::syncCatalog() {
|
||||
global::toast::modalToast = true;
|
||||
global::toast::indefiniteToast = true;
|
||||
bool syncDone = false;
|
||||
log("Gutenberg sync in progress", className);
|
||||
showToast("Sync in progress");
|
||||
QTimer::singleShot(500, this, SLOT(syncCatalogSlot()));
|
||||
}
|
||||
|
||||
void libraryWidget::syncCatalogSlot() {
|
||||
bool syncDone = false;
|
||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||
QTimer * syncCheckTimer = new QTimer(this);
|
||||
syncCheckTimer->setInterval(500);
|
||||
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
||||
while(true) {
|
||||
if(syncDone == false) {
|
||||
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
||||
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
|
||||
|
@ -286,10 +287,11 @@ void libraryWidget::syncCatalog() {
|
|||
}
|
||||
QFile::remove("/inkbox/gutenbergSyncDone");
|
||||
syncDone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
syncCheckTimer->start();
|
||||
QThread::msleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
void libraryWidget::on_previousBtn_clicked()
|
||||
|
|
|
@ -29,6 +29,7 @@ private:
|
|||
|
||||
private slots:
|
||||
void syncCatalog();
|
||||
void syncCatalogSlot();
|
||||
void setupView();
|
||||
void showToast(QString messageToDisplay);
|
||||
void closeIndefiniteToast();
|
||||
|
|
Loading…
Reference in a new issue