mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Propagate updates to all the parent folders
This commit is contained in:
parent
14fccb01d0
commit
682f5761b2
@ -1292,13 +1292,22 @@ qulonglong DBHelper::insert(ComicDB *comic, QSqlDatabase &db, bool insertAllInfo
|
|||||||
query.bindValue(":path", comic->path);
|
query.bindValue(":path", comic->path);
|
||||||
query.exec();
|
query.exec();
|
||||||
|
|
||||||
|
// loop through parents and update their updated field
|
||||||
|
// TODO: use stored procedures
|
||||||
QSqlQuery updateFolder(db);
|
QSqlQuery updateFolder(db);
|
||||||
updateFolder.prepare("UPDATE folder SET "
|
updateFolder.prepare("UPDATE folder SET "
|
||||||
"updated = :updated "
|
"updated = :updated "
|
||||||
"WHERE id = :id ");
|
"WHERE id = :id ");
|
||||||
updateFolder.bindValue(":updated", added);
|
auto currentParentId = comic->parentId;
|
||||||
updateFolder.bindValue(":id", comic->parentId);
|
while (currentParentId != 1 && currentParentId != 0) {
|
||||||
updateFolder.exec();
|
updateFolder.bindValue(":updated", added);
|
||||||
|
updateFolder.bindValue(":id", currentParentId);
|
||||||
|
updateFolder.exec();
|
||||||
|
|
||||||
|
auto f = loadFolder(currentParentId, db);
|
||||||
|
currentParentId = f.parentId;
|
||||||
|
}
|
||||||
|
//----
|
||||||
|
|
||||||
return query.lastInsertId().toULongLong();
|
return query.lastInsertId().toULongLong();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user