diff --git a/gpt4all-chat/CHANGELOG.md b/gpt4all-chat/CHANGELOG.md index 4c407096..335177f3 100644 --- a/gpt4all-chat/CHANGELOG.md +++ b/gpt4all-chat/CHANGELOG.md @@ -12,6 +12,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). ### Changed - Implement Qt 6.8 compatibility ([#3121](https://github.com/nomic-ai/gpt4all/pull/3121)) +### Fixed +- Fix bug in GUI when localdocs encounters binary data ([#3137](https://github.com/nomic-ai/gpt4all/pull/3137)) + ## [3.4.2] - 2024-10-16 ### Fixed diff --git a/gpt4all-chat/src/database.cpp b/gpt4all-chat/src/database.cpp index 1b86caac..5519c31e 100644 --- a/gpt4all-chat/src/database.cpp +++ b/gpt4all-chat/src/database.cpp @@ -1355,7 +1355,8 @@ ChunkStreamer::Status ChunkStreamer::step() for (;;) { if (auto error = m_reader->getError()) { m_docKey.reset(); // done processing - return *error; + retval = *error; + break; } // get a word, if needed @@ -1515,8 +1516,22 @@ void Database::handleEmbeddingsGenerated(const QVector &embeddi for (const auto &[key, stat]: std::as_const(stats).asKeyValueRange()) { if (!m_collectionMap.contains(key.folder_id)) continue; CollectionItem item = guiCollectionItem(key.folder_id); - item.currentEmbeddingsToIndex -= stat.nAdded + stat.nSkipped; - item.totalEmbeddingsToIndex -= stat.nSkipped; + Q_ASSERT(item.currentEmbeddingsToIndex >= stat.nAdded + stat.nSkipped); + if (item.currentEmbeddingsToIndex < stat.nAdded + stat.nSkipped) { + qWarning() << "Database ERROR: underflow in current embeddings to index statistics"; + item.currentEmbeddingsToIndex = 0; + } else { + item.currentEmbeddingsToIndex -= stat.nAdded + stat.nSkipped; + } + + Q_ASSERT(item.totalEmbeddingsToIndex >= stat.nSkipped); + if (item.totalEmbeddingsToIndex < stat.nSkipped) { + qWarning() << "Database ERROR: underflow in total embeddings to index statistics"; + item.totalEmbeddingsToIndex = 0; + } else { + item.totalEmbeddingsToIndex -= stat.nSkipped; + } + if (!stat.lastFile.isNull()) item.fileCurrentlyProcessing = stat.lastFile; @@ -1746,7 +1761,13 @@ void Database::scanQueue() dequeue: auto item = guiCollectionItem(folder_id); - item.currentBytesToIndex -= info.file.size(); + Q_ASSERT(item.currentBytesToIndex >= info.file.size()); + if (item.currentBytesToIndex < info.file.size()) { + qWarning() << "Database ERROR: underflow in current bytes to index statistics"; + item.currentBytesToIndex = 0; + } else { + item.currentBytesToIndex -= info.file.size(); + } updateGuiForCollectionItem(item); return updateFolderToIndex(folder_id, countForFolder); }