mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
Purge unused info and covers after full library updates
This commit is contained in:
parent
72535ffc98
commit
dc4010aec0
@ -228,11 +228,13 @@ void LibraryCreator::run()
|
|||||||
if (partialUpdate) {
|
if (partialUpdate) {
|
||||||
auto folder = DBHelper::updateChildrenInfo(folderDestinationModelIndex.data(FolderModel::IdRole).toULongLong(), _database);
|
auto folder = DBHelper::updateChildrenInfo(folderDestinationModelIndex.data(FolderModel::IdRole).toULongLong(), _database);
|
||||||
DBHelper::propagateFolderUpdatesToParent(folder, _database);
|
DBHelper::propagateFolderUpdatesToParent(folder, _database);
|
||||||
} else
|
} else {
|
||||||
DBHelper::updateChildrenInfo(_database);
|
DBHelper::updateChildrenInfo(_database);
|
||||||
|
cleanup(_database, _target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_database.commit();
|
_database.commit();
|
||||||
}
|
|
||||||
_database.close();
|
_database.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,6 +272,38 @@ void LibraryCreator::cancel()
|
|||||||
stopRunning = true;
|
stopRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LibraryCreator::cleanup(QSqlDatabase &db, const QString &target)
|
||||||
|
{
|
||||||
|
QDir coversDir(target + "/covers/");
|
||||||
|
if (!coversDir.exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete from comic_info all the comics that don't have a comic associated from the comic table
|
||||||
|
QSqlQuery infoToDeleteQuery(db);
|
||||||
|
infoToDeleteQuery.prepare("SELECT ci.id, ci.hash FROM comic_info ci WHERE ci.id NOT IN (SELECT c.comicInfoId FROM comic c)");
|
||||||
|
|
||||||
|
if (!infoToDeleteQuery.exec()) {
|
||||||
|
QLOG_ERROR() << "Error getting comics to delete";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (infoToDeleteQuery.next()) {
|
||||||
|
QString hash = infoToDeleteQuery.value(1).toString();
|
||||||
|
QString cover = hash + ".jpg";
|
||||||
|
|
||||||
|
auto fullPath = coversDir.absoluteFilePath(cover);
|
||||||
|
QFile::remove(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSqlQuery deleteQuery(db);
|
||||||
|
deleteQuery.prepare("DELETE FROM comic_info WHERE id NOT IN (SELECT comicInfoId FROM comic)");
|
||||||
|
if (!deleteQuery.exec()) {
|
||||||
|
QLOG_ERROR() << "Error purging info from comic_info";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// retorna el id del ultimo de los folders
|
// retorna el id del ultimo de los folders
|
||||||
qulonglong LibraryCreator::insertFolders()
|
qulonglong LibraryCreator::insertFolders()
|
||||||
{
|
{
|
||||||
|
@ -59,6 +59,7 @@ private:
|
|||||||
QModelIndex folderDestinationModelIndex;
|
QModelIndex folderDestinationModelIndex;
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
bool checkModifiedDatesOnUpdate;
|
bool checkModifiedDatesOnUpdate;
|
||||||
|
void cleanup(QSqlDatabase &db, const QString &target);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user