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);
|
QTextStream in (&config);
|
||||||
const QString content = in.readAll();
|
const QString content = in.readAll();
|
||||||
std::string contentstr = content.toStdString();
|
std::string contentstr = content.toStdString();
|
||||||
|
config.close();
|
||||||
if(contentstr.find("true") != std::string::npos) {
|
if(contentstr.find("true") != std::string::npos) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
config.close();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -282,13 +282,13 @@ namespace {
|
||||||
QTextStream in (&config);
|
QTextStream in (&config);
|
||||||
const QString content = in.readAll();
|
const QString content = in.readAll();
|
||||||
std::string contentstr = content.toStdString();
|
std::string contentstr = content.toStdString();
|
||||||
|
config.close();
|
||||||
if(contentstr.find("true") != std::string::npos) {
|
if(contentstr.find("true") != std::string::npos) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
config.close();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -485,6 +485,7 @@ namespace {
|
||||||
QTextStream in (&config);
|
QTextStream in (&config);
|
||||||
const QString content = in.readAll();
|
const QString content = in.readAll();
|
||||||
std::string contentstr = content.toStdString();
|
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
|
// 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");
|
std::regex r("\\b" + pattern + "\\b");
|
||||||
|
@ -496,7 +497,6 @@ namespace {
|
||||||
else {
|
else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
config.close();
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
bool isBatteryLow() {
|
bool isBatteryLow() {
|
||||||
|
|
|
@ -264,14 +264,15 @@ void libraryWidget::closeIndefiniteToast() {
|
||||||
void libraryWidget::syncCatalog() {
|
void libraryWidget::syncCatalog() {
|
||||||
global::toast::modalToast = true;
|
global::toast::modalToast = true;
|
||||||
global::toast::indefiniteToast = true;
|
global::toast::indefiniteToast = true;
|
||||||
bool syncDone = false;
|
|
||||||
log("Gutenberg sync in progress", className);
|
log("Gutenberg sync in progress", className);
|
||||||
showToast("Sync in progress");
|
showToast("Sync in progress");
|
||||||
|
QTimer::singleShot(500, this, SLOT(syncCatalogSlot()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void libraryWidget::syncCatalogSlot() {
|
||||||
|
bool syncDone = false;
|
||||||
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
string_writeconfig("/opt/ibxd", "gutenberg_sync\n");
|
||||||
QTimer * syncCheckTimer = new QTimer(this);
|
while(true) {
|
||||||
syncCheckTimer->setInterval(500);
|
|
||||||
connect(syncCheckTimer, &QTimer::timeout, [&]() {
|
|
||||||
if(syncDone == false) {
|
if(syncDone == false) {
|
||||||
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
if(QFile::exists("/inkbox/gutenbergSyncDone") == true) {
|
||||||
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
|
if(checkconfig("/inkbox/gutenbergSyncDone") == true) {
|
||||||
|
@ -286,10 +287,11 @@ void libraryWidget::syncCatalog() {
|
||||||
}
|
}
|
||||||
QFile::remove("/inkbox/gutenbergSyncDone");
|
QFile::remove("/inkbox/gutenbergSyncDone");
|
||||||
syncDone = true;
|
syncDone = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
QThread::msleep(500);
|
||||||
syncCheckTimer->start();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void libraryWidget::on_previousBtn_clicked()
|
void libraryWidget::on_previousBtn_clicked()
|
||||||
|
|
|
@ -29,6 +29,7 @@ private:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void syncCatalog();
|
void syncCatalog();
|
||||||
|
void syncCatalogSlot();
|
||||||
void setupView();
|
void setupView();
|
||||||
void showToast(QString messageToDisplay);
|
void showToast(QString messageToDisplay);
|
||||||
void closeIndefiniteToast();
|
void closeIndefiniteToast();
|
||||||
|
|
Loading…
Reference in a new issue