From fa10409a31587e5309d6121988669f967809eb25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 7 Jun 2023 22:42:40 +0200 Subject: [PATCH] Check the file size when updating and only compare the dates if it's enabled --- YACReaderLibrary/library_creator.cpp | 9 +++++++-- YACReaderLibrary/library_creator.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/YACReaderLibrary/library_creator.cpp b/YACReaderLibrary/library_creator.cpp index 8784b155..46bb0c25 100644 --- a/YACReaderLibrary/library_creator.cpp +++ b/YACReaderLibrary/library_creator.cpp @@ -40,12 +40,14 @@ void LibraryCreator::createLibrary(const QString &source, const QString &target) void LibraryCreator::updateLibrary(const QString &source, const QString &target) { + checkModifiedDatesOnUpdate = settings->value(COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES, false).toBool(); partialUpdate = false; processLibrary(source, target); } void LibraryCreator::updateFolder(const QString &source, const QString &target, const QString &sourceFolder, const QModelIndex &dest) { + checkModifiedDatesOnUpdate = settings->value(COMPARE_MODIFIED_DATE_ON_LIBRARY_UPDATES, false).toBool(); partialUpdate = true; folderDestinationModelIndex = dest; @@ -571,14 +573,17 @@ void LibraryCreator::update(QDir dirS) { DBHelper::removeFromDB(fileInfoD, _database); j++; - } else // same file + } else // file with the same name { if (fileInfoS.isFile() && !fileInfoD->isDir()) { auto comicDB = static_cast(fileInfoD); auto lastModified = fileInfoS.lastModified().toSecsSinceEpoch(); auto added = comicDB->info.added.toULongLong(); - if (added > 0 && added < lastModified) { + auto sizeHasChanged = comicDB->getFileSize() != fileInfoS.size(); + auto hasBeenModified = added > 0 && added < lastModified && checkModifiedDatesOnUpdate; + + if (sizeHasChanged || hasBeenModified) { #ifdef Q_OS_MACOS QStringList src = _source.split("/"); QString filePath = fileInfoS.absoluteFilePath(); diff --git a/YACReaderLibrary/library_creator.h b/YACReaderLibrary/library_creator.h index e891893b..4b6e9d5c 100644 --- a/YACReaderLibrary/library_creator.h +++ b/YACReaderLibrary/library_creator.h @@ -56,6 +56,7 @@ private: bool partialUpdate; QModelIndex folderDestinationModelIndex; QSettings *settings; + bool checkModifiedDatesOnUpdate; signals: void finished();