aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-09-08 16:51:29 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-09-08 16:51:29 (GMT)
commit4d83c90496deed2110b1d21e177de857ed6b5698 (patch)
treec809aca2fc6ea31836bef4b390f1d06a4fb37385
parentab1ddb2a848cea10599fa4dd322b5bb8e4415a7a (diff)
Fix attribute external part cleanup
The most evil typo ever.
-rw-r--r--src/server/storage/parthelper.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/storage/parthelper.cpp b/src/server/storage/parthelper.cpp
index 431b1ac..1825975 100644
--- a/src/server/storage/parthelper.cpp
+++ b/src/server/storage/parthelper.cpp
@@ -50,13 +50,17 @@ void PartHelper::update(Part *part, const QByteArray &data, qint64 dataSize)
throw PartHelperException(QStringLiteral("Failed to update external payload part"));
}
part->setData(newFile);
- } if (!part->external() && storeExternal) {
+ } else if (!part->external() && storeExternal) {
if (!ExternalPartStorage::self()->createPartFile(data, part->id(), newFile)) {
throw PartHelperException(QStringLiteral("Failed to create external payload part"));
}
part->setData(newFile);
part->setExternal(true);
} else {
+ if (part->external() && !storeExternal) {
+ const QString file = ExternalPartStorage::resolveAbsolutePath(part->data());
+ ExternalPartStorage::self()->removePartFile(file);
+ }
part->setData(data);
part->setExternal(false);
}
@@ -74,8 +78,9 @@ bool PartHelper::insert(Part *part, qint64 *insertId)
return false;
}
- const bool storeInFile = part->datasize() > DbConfig::configuredDatabase()->sizeThreshold();
+ Q_ASSERT(!part->isValid());
+ const bool storeInFile = part->datasize() > DbConfig::configuredDatabase()->sizeThreshold();
//it is needed to insert first the metadata so a new id is generated for the part,
//and we need this id for the payload file name
QByteArray data;