diff --git a/YACReaderLibrary/db_helper.cpp b/YACReaderLibrary/db_helper.cpp index 081a51f0..df81d4c7 100644 --- a/YACReaderLibrary/db_helper.cpp +++ b/YACReaderLibrary/db_helper.cpp @@ -771,6 +771,41 @@ void DBHelper::updateFromRemoteClient(qulonglong libraryId,const ComicInfo & com QSqlDatabase::removeDatabase(db.connectionName()); } +void DBHelper::updateFromRemoteClientWithHash(const ComicInfo & comicInfo) +{ + YACReaderLibraries libraries = DBHelper::getLibraries(); + + QStringList names = libraries.getNames(); + + foreach (QString name, names) { + QString libraryPath = DBHelper::getLibraries().getPath(libraries.getId(name)); + + QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary"); + + ComicInfo info = loadComicInfo(comicInfo.hash, db); + + if(comicInfo.currentPage > 0) + { + info.currentPage = comicInfo.currentPage; + + if(info.currentPage == info.numPages) + info.read = true; + else + info.lastTimeOpened = QDateTime::currentSecsSinceEpoch(); + + info.hasBeenOpened = true; + } + + if(comicInfo.rating > 0) + info.rating = comicInfo.rating; + + DBHelper::update(&info, db); + + db.close(); + QSqlDatabase::removeDatabase(db.connectionName()); + } +} + void DBHelper::renameLabel(qulonglong id, const QString &name, QSqlDatabase &db) { QSqlQuery renameLabelQuery(db); diff --git a/YACReaderLibrary/db_helper.h b/YACReaderLibrary/db_helper.h index c1faf0d3..3e732747 100644 --- a/YACReaderLibrary/db_helper.h +++ b/YACReaderLibrary/db_helper.h @@ -71,6 +71,7 @@ public: static void setComicAsReading(qulonglong libraryId, const ComicInfo &comicInfo); static void updateReadingRemoteProgress(const ComicInfo & comicInfo, QSqlDatabase & db); static void updateFromRemoteClient(qulonglong libraryId,const ComicInfo & comicInfo); + static void updateFromRemoteClientWithHash(const ComicInfo & comicInfo); static void renameLabel(qulonglong id, const QString & name, QSqlDatabase & db); static void renameList(qulonglong id, const QString & name, QSqlDatabase & db); static void reasignOrderToSublists(QList ids, QSqlDatabase & db);