From 768c1077b0d226d832f34904e929c2462eca158f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 16 Feb 2017 10:29:27 +0100 Subject: Remember whether a blob property is external or not. ...we used to accidentally move external blobs after the property was lost when storing the modificatoin in the queue. --- common/domain/applicationdomaintype.h | 2 +- common/propertymapper.cpp | 12 ++++++++++-- common/storage/entitystore.cpp | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'common') diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 98b7de7..7380c04 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -280,7 +280,7 @@ inline QDebug operator<< (QDebug d, const Reference &ref) inline QDebug operator<< (QDebug d, const BLOB &blob) { - d << blob.value; + d << blob.value << "external:" << blob.isExternal ; return d; } diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 4cfe154..4d45644 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp @@ -36,7 +36,9 @@ template <> flatbuffers::uoffset_t variantToProperty(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) { if (property.isValid()) { - return fbb.CreateString(property.value().value.toStdString()).o; + const auto blob = property.value(); + auto s = blob.value + (blob.isExternal ? ":ext" : ":int"); + return fbb.CreateString(s.toStdString()).o; } return 0; } @@ -133,7 +135,13 @@ QVariant propertyToVariant(const flatbuffers::Str { if (property) { // We have to copy the memory, otherwise it would become eventually invalid - return QVariant::fromValue(Sink::ApplicationDomain::BLOB{QString::fromStdString(property->c_str())}); + auto s = QString::fromStdString(property->c_str()); + auto ext = s.endsWith(":ext"); + s.chop(4); + + auto blob = Sink::ApplicationDomain::BLOB{s}; + blob.isExternal = ext; + return QVariant::fromValue(blob); } return QVariant(); } diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 51e5da7..9156dd4 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -162,6 +162,7 @@ void EntityStore::copyBlobs(ApplicationDomain::ApplicationDomainType &entity, qi SinkWarningCtx(d->logCtx) << "Failed to move the file from: " << oldPath << " to " << filePath << ". " << origFile.errorString(); } origFile.close(); + SinkTraceCtx(d->logCtx) << "Moved blob property: " << property << " from " << oldPath << "to" << filePath; entity.setProperty(property, QVariant::fromValue(ApplicationDomain::BLOB{filePath})); } } -- cgit v1.2.3