Revert "Due to perfomance issues at openboard start, in a network-attached storage context, I had to find some (dirty) optimizations in order to counter-balance the huge response time of the directory scans performed when creating the documents tree (very huge in slowest machines (HDD, low CPU, with a thousand documents)). The simplest solution (I found) was to let the opening of metadatas fail, and to prevent any scanning. This implied to introduce the page-count as a metadata. As this issue is not encountered with a standard use of OpenBoard (with local documents), no update operation (of every document) should be necessary out of the described context"

This reverts commit 9adb8e6643.
preferencesAboutTextFull
Clément Fauconnier 4 years ago
parent 43f2aba2cc
commit 19e6331f5d
  1. 7
      src/adaptors/UBMetadataDcSubsetAdaptor.cpp
  2. 22
      src/core/UBPersistenceManager.cpp
  3. 1
      src/core/UBSettings.cpp
  4. 1
      src/core/UBSettings.h
  5. 12
      src/document/UBDocumentProxy.cpp
  6. 1
      src/document/UBDocumentProxy.h

@ -125,8 +125,6 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
// introduced in UB 4.4 // introduced in UB 4.4
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTimeUtc())); xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTimeUtc()));
xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "page-count", QString::number(proxy->pageCount()));
xmlWriter.writeEndElement(); //dc:Description xmlWriter.writeEndElement(); //dc:Description
xmlWriter.writeEndElement(); //RDF xmlWriter.writeEndElement(); //RDF
@ -226,11 +224,6 @@ QMap<QString, QVariant> UBMetadataDcSubsetAdaptor::load(QString pPath)
metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText()); metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText());
updatedAtFound = true; updatedAtFound = true;
} }
else if (xml.name() == "page-count"
&& xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri)
{
metadata.insert(UBSettings::documentPageCount, xml.readElementText());
}
metadata.insert(UBSettings::documentVersion, docVersion); metadata.insert(UBSettings::documentVersion, docVersion);
} }

@ -164,8 +164,11 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c
{ {
QString fullPath = path.absoluteFilePath(); QString fullPath = path.absoluteFilePath();
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(fullPath); QDir dir(fullPath);
if (dir.entryList(QDir::Files | QDir::NoDotAndDotDot).size() > 0)
{
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(fullPath);
QString docGroupName = metadatas.value(UBSettings::documentGroupName, QString()).toString(); QString docGroupName = metadatas.value(UBSettings::documentGroupName, QString()).toString();
QString docName = metadatas.value(UBSettings::documentName, QString()).toString(); QString docName = metadatas.value(UBSettings::documentName, QString()).toString();
@ -179,24 +182,12 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c
return; return;
} }
UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath, metadatas); // managed in UBDocumentTreeNode UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath); // managed in UBDocumentTreeNode
foreach(QString key, metadatas.keys()) { foreach(QString key, metadatas.keys()) {
docProxy->setMetaData(key, metadatas.value(key)); docProxy->setMetaData(key, metadatas.value(key));
} }
if (metadatas.contains(UBSettings::documentPageCount)) docProxy->setPageCount(sceneCount(docProxy));
{
int pageCount = metadatas.value(UBSettings::documentPageCount).toInt();
if (pageCount == 0)
pageCount = sceneCount(docProxy);
docProxy->setPageCount(pageCount);
}
else
{
int pageCount = sceneCount(docProxy);
docProxy->setPageCount(pageCount);
}
if (!interactive) if (!interactive)
mDocumentTreeStructureModel->addDocument(docProxy, parentIndex); mDocumentTreeStructureModel->addDocument(docProxy, parentIndex);
@ -204,6 +195,7 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c
processInteractiveReplacementDialog(docProxy); processInteractiveReplacementDialog(docProxy);
} }
} }
}
QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy) QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy)
{ {

@ -61,7 +61,6 @@ QString UBSettings::documentSize = QString("Size");
QString UBSettings::documentIdentifer = QString("ID"); QString UBSettings::documentIdentifer = QString("ID");
QString UBSettings::documentVersion = QString("Version"); QString UBSettings::documentVersion = QString("Version");
QString UBSettings::documentUpdatedAt = QString("UpdatedAt"); QString UBSettings::documentUpdatedAt = QString("UpdatedAt");
QString UBSettings::documentPageCount = QString("PageCount");
QString UBSettings::documentDate = QString("date"); QString UBSettings::documentDate = QString("date");
QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:");

@ -202,7 +202,6 @@ class UBSettings : public QObject
static QString documentIdentifer; static QString documentIdentifer;
static QString documentVersion; static QString documentVersion;
static QString documentUpdatedAt; static QString documentUpdatedAt;
static QString documentPageCount;
static QString documentDate; static QString documentDate;

@ -56,6 +56,7 @@ UBDocumentProxy::UBDocumentProxy(const UBDocumentProxy &rValue) :
mPageCount = rValue.mPageCount; mPageCount = rValue.mPageCount;
} }
UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath) UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath)
: mPageCount(0) : mPageCount(0)
, mPageDpi(0) , mPageDpi(0)
@ -67,17 +68,6 @@ UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath)
} }
UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath, QMap<QString, QVariant> metadatas)
: mPageCount(0)
, mPageDpi(0)
{
init();
setPersistencePath(pPersistancePath);
mMetaDatas = metadatas;
}
void UBDocumentProxy::init() void UBDocumentProxy::init()
{ {
setMetaData(UBSettings::documentGroupName, ""); setMetaData(UBSettings::documentGroupName, "");

@ -49,7 +49,6 @@ class UBDocumentProxy : public QObject
UBDocumentProxy(); UBDocumentProxy();
UBDocumentProxy(const UBDocumentProxy &rValue); UBDocumentProxy(const UBDocumentProxy &rValue);
UBDocumentProxy(const QString& pPersistencePath); UBDocumentProxy(const QString& pPersistencePath);
UBDocumentProxy(const QString& pPersistencePath, QMap<QString, QVariant> metadatas);
virtual ~UBDocumentProxy(); virtual ~UBDocumentProxy();

Loading…
Cancel
Save