Skip to content

Commit

Permalink
Added safety to prevent duplication error when getting file hash fails
Browse files Browse the repository at this point in the history
DavidLazarescu committed Dec 13, 2023
1 parent 4f94cfb commit 862611a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/application/services/library_service.cpp
Original file line number Diff line number Diff line change
@@ -120,7 +120,9 @@ BookOperationStatus LibraryService::addBook(const QString& filePath,

auto bookMetaData = m_bookMetadataHelper->getBookMetaData();
Book book(filePath, bookMetaData);
if(!allowDuplicates && bookWithFileHashAlreadyExists(book.getFileHash()))
auto hash = book.getFileHash();
if(!allowDuplicates && !hash.isEmpty() &&
bookWithFileHashAlreadyExists(hash))
{
qWarning() << QString("Book with file hash: %1 already exists.")
.arg(book.getFileHash());

0 comments on commit 862611a

Please sign in to comment.