Commit 9a4dcb1b authored by Simeon Bird's avatar Simeon Bird
Browse files

Indexer and epubextractor: check more carefully that graphs are

not empty.

In particular, in the indexer we check that the graph is
non-empty, but then we remove the plain text content, so we need to
check again.

BUG: 324307
REVIEW: 112476
parent 37f5c9df
......@@ -215,7 +215,8 @@ SimpleResourceGraph EPubExtractor::extract(const QUrl& resUri, const QUrl& fileU
if( !plainText.isEmpty() )
fileRes.addProperty( NIE::plainTextContent(), plainText );
graph << fileRes;
if( fileRes.isValid() )
graph << fileRes;
return graph;
}
......
......@@ -154,20 +154,27 @@ bool Nepomuk2::Indexer::fileIndex(const QUrl& uri, const QUrl& url, const QStrin
if( vl.size() == 1 ) {
plainText = vl.first().toString();
graph[uri].remove( NIE::plainTextContent() );
// Check that the SimpleResource is still valid:
// if it only contained text it may not be.
if ( !graph[uri].isValid() )
graph.remove(uri);
}
QHash<QUrl, QVariant> additionalMetadata;
additionalMetadata.insert( RDF::type(), NRL::DiscardableInstanceBase() );
// we do not have an event loop - thus, we need to delete the job ourselves
QScopedPointer<StoreResourcesJob> job( Nepomuk2::storeResources( graph, IdentifyNew,
NoStoreResourcesFlags, additionalMetadata ) );
job->setAutoDelete(false);
job->exec();
if( job->error() ) {
m_lastError = job->errorString();
kError() << "SimpleIndexerError: " << m_lastError;
return false;
// Check again that the graph is not empty: it may have only contained text
if( !graph.isEmpty() ) {
QHash<QUrl, QVariant> additionalMetadata;
additionalMetadata.insert( RDF::type(), NRL::DiscardableInstanceBase() );
// we do not have an event loop - thus, we need to delete the job ourselves
QScopedPointer<StoreResourcesJob> job( Nepomuk2::storeResources( graph, IdentifyNew,
NoStoreResourcesFlags, additionalMetadata ) );
job->setAutoDelete(false);
job->exec();
if( job->error() ) {
m_lastError = job->errorString();
kError() << "SimpleIndexerError: " << m_lastError;
return false;
}
}
if( plainText.length() ) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment