Commit 85938288 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Rename Part.external bool column to Part.storage enum

For now the enum only has Internal and External values,
but we will extend this eventually with another value.
parent d257ae7c
......@@ -431,13 +431,13 @@ void ProtocolTest::testPartMetaData()
in.setName("PLD:HEAD");
in.setSize(42);
in.setVersion(1);
in.setIsExternal(true);
in.setStorageType(PartMetaData::External);
const PartMetaData out = serializeAndDeserialize(in);
QCOMPARE(out.name(), QByteArray("PLD:HEAD"));
QCOMPARE(out.size(), 42);
QCOMPARE(out.version(), 1);
QCOMPARE(out.isExternal(), true);
QCOMPARE(out.storageType(), PartMetaData::External);
QCOMPARE(out, in);
const bool notEquals = (in != out);
QVERIFY(!notEquals);
......
......@@ -84,18 +84,18 @@ public:
struct PartHelper
{
PartHelper(const QString &type_, const QByteArray &data_, int size_, bool external_ = false, int version_ = 0)
PartHelper(const QString &type_, const QByteArray &data_, int size_, Part::Storage storage_ = Part::Internal, int version_ = 0)
: type(type_)
, data(data_)
, size(size_)
, external(external_)
, storage(storage_)
, version(version_)
{
}
QString type;
QByteArray data;
int size;
bool external;
Part::Storage storage;
int version;
};
......@@ -110,7 +110,7 @@ public:
part.setPartType(PartType(types[1], types[0]));
part.setData(helper.data);
part.setDatasize(helper.size);
part.setExternal(helper.external);
part.setStorage(helper.storage);
part.setVersion(helper.version);
parts << part;
}
......@@ -760,7 +760,7 @@ private Q_SLOTS:
QCOMPARE(QString::fromUtf8(actualPart.data()), QString::fromUtf8(part.data()));
QCOMPARE(actualPart.data(), part.data());
QCOMPARE(actualPart.datasize(), part.datasize());
QCOMPARE(actualPart.external(), part.external());
QCOMPARE(actualPart.storage(), part.storage());
}
}
}
......
......@@ -39,6 +39,7 @@ using namespace Akonadi;
using namespace Akonadi::Server;
Q_DECLARE_METATYPE(Akonadi::Server::PimItem)
Q_DECLARE_METATYPE(Akonadi::Server::Part::Storage)
class PartStreamerTest : public QObject
{
......@@ -81,7 +82,7 @@ private Q_SLOTS:
QTest::addColumn<QByteArray>("expectedFileData");
QTest::addColumn<qint64>("expectedPartSize");
QTest::addColumn<bool>("expectedChanged");
QTest::addColumn<bool>("isExternal");
QTest::addColumn<Part::Storage>("storage");
QTest::addColumn<PimItem>("pimItem");
PimItem item;
......@@ -110,7 +111,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA", "123"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 1));
QTest::newRow("item 1, internal") << scenarios << QByteArray("PLD:DATA") << QByteArray("123") << QByteArray() << 3ll << true << false << item;
QTest::newRow("item 1, internal") << scenarios << QByteArray("PLD:DATA") << QByteArray("123") << QByteArray() << 3ll << true << Part::Internal << item;
}
{
......@@ -123,7 +124,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 2));
QTest::newRow("item 1, change to external") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r0") << QByteArray("123456789") << 9ll << true << true << item;
QTest::newRow("item 1, change to external") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r0") << QByteArray("123456789") << 9ll << true << Part::External << item;
}
{
......@@ -136,7 +137,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 3));
QTest::newRow("item 1, update external") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r1") << QByteArray("987654321") << 9ll << true << true << item;
QTest::newRow("item 1, update external") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r1") << QByteArray("987654321") << 9ll << true << Part::External << item;
}
{
......@@ -149,7 +150,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 4));
QTest::newRow("item 1, external, no change") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r2") << QByteArray("987654321") << 9ll << false << true << item;
QTest::newRow("item 1, external, no change") << scenarios << QByteArray("PLD:DATA") << QByteArray("15_r2") << QByteArray("987654321") << 9ll << false << Part::External << item;
}
{
......@@ -162,7 +163,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA", "1234"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 5));
QTest::newRow("item 1, change to internal") << scenarios << QByteArray("PLD:DATA") << QByteArray("1234") << QByteArray() << 4ll << true << false << item;
QTest::newRow("item 1, change to internal") << scenarios << QByteArray("PLD:DATA") << QByteArray("1234") << QByteArray() << 4ll << true << Part::Internal << item;
}
{
......@@ -175,7 +176,7 @@ private Q_SLOTS:
<< TestScenario::create(5, TestScenario::ClientCmd, Protocol::StreamPayloadResponse("PLD:DATA", "1234"))
<< TestScenario::create(5, TestScenario::ServerCmd, Protocol::ModifyItemsResponse(item.id(), 6));
QTest::newRow("item 1, internal, no change") << scenarios << QByteArray("PLD:DATA") << QByteArray("1234") << QByteArray() << 4ll << false << false << item;
QTest::newRow("item 1, internal, no change") << scenarios << QByteArray("PLD:DATA") << QByteArray("1234") << QByteArray() << 4ll << false << Part::Internal << item;
}
}
......@@ -186,10 +187,10 @@ private Q_SLOTS:
QFETCH(QByteArray, expectedPartData);
QFETCH(QByteArray, expectedFileData);
QFETCH(qint64, expectedPartSize);
QFETCH(bool, isExternal);
QFETCH(Part::Storage, storage);
QFETCH(PimItem, pimItem);
if (isExternal) {
if (storage == Part::External) {
// Create the payload file now, since don't have means to react
// directly to the streaming command
QFile file(ExternalPartStorage::resolveAbsolutePath(expectedPartData));
......@@ -206,10 +207,10 @@ private Q_SLOTS:
QVERIFY(parts.count() == 1);
const Part part = parts[0];
QCOMPARE(part.datasize(), expectedPartSize);
QCOMPARE(part.external(), isExternal);
QCOMPARE(part.storage(), storage);
const QByteArray data = part.data();
if (isExternal) {
if (storage == Part::External) {
QCOMPARE(data, expectedPartData);
QFile file(ExternalPartStorage::resolveAbsolutePath(data));
QVERIFY(file.exists());
......
......@@ -476,14 +476,15 @@ Item ProtocolHelper::parseItemFetchResult(const Protocol::FetchItemsResponse &da
Q_FOREACH (const Protocol::StreamPayloadResponse &part, data.parts()) {
ProtocolHelper::PartNamespace ns;
const QByteArray plainKey = decodePartIdentifier(part.payloadName(), ns);
const auto metaData = part.metaData();
switch (ns) {
case ProtocolHelper::PartPayload:
ItemSerializer::deserialize(item, plainKey, part.data(), part.metaData().version(), part.metaData().isExternal());
ItemSerializer::deserialize(item, plainKey, part.data(), metaData.version(), metaData.storageType());
break;
case ProtocolHelper::PartAttribute: {
Attribute *attr = AttributeFactory::createAttribute(plainKey);
Q_ASSERT(attr);
if (part.metaData().isExternal()) {
if (metaData.storageType() == Protocol::PartMetaData::External) {
const QString filename = ExternalPartStorage::resolveAbsolutePath(part.data());
QFile file(filename);
if (file.open(QFile::ReadOnly)) {
......
......@@ -1062,12 +1062,12 @@ class PartMetaDataPrivate : public QSharedData
{
public:
PartMetaDataPrivate(const QByteArray &name = QByteArray(), qint64 size = 0,
int version = 0, bool external = false)
int version = 0, PartMetaData::StorageType storageType = PartMetaData::Internal)
: QSharedData()
, name(name)
, size(size)
, version(version)
, external(external)
, storageType(storageType)
{}
PartMetaDataPrivate(const PartMetaDataPrivate &other)
......@@ -1075,13 +1075,13 @@ public:
, name(other.name)
, size(other.size)
, version(other.version)
, external(other.external)
, storageType(other.storageType)
{}
QByteArray name;
qint64 size;
int version;
bool external;
PartMetaData::StorageType storageType;
};
PartMetaData::PartMetaData()
......@@ -1089,8 +1089,9 @@ PartMetaData::PartMetaData()
{
}
PartMetaData::PartMetaData(const QByteArray &name, qint64 size, int version, bool external)
: d(new PartMetaDataPrivate(name, size, version, external))
PartMetaData::PartMetaData(const QByteArray &name, qint64 size, int version,
StorageType storageType)
: d(new PartMetaDataPrivate(name, size, version, storageType))
{
}
......@@ -1126,7 +1127,7 @@ bool PartMetaData::operator==(const PartMetaData &other) const
|| (d->name == other.d->name
&& d->size == other.d->size
&& d->version == other.d->version
&& d->external == other.d->external);
&& d->storageType == other.d->storageType);
}
bool PartMetaData::operator!=(const PartMetaData &other) const
......@@ -1166,13 +1167,14 @@ int PartMetaData::version() const
return d->version;
}
void PartMetaData::setIsExternal(bool external)
void PartMetaData::setStorageType(StorageType storageType)
{
d->external = external;
d->storageType = storageType;
}
bool PartMetaData::isExternal() const
PartMetaData::StorageType PartMetaData::storageType() const
{
return d->external;
return d->storageType;
}
DataStream &operator<<(DataStream &stream, const PartMetaData &part)
......@@ -1180,7 +1182,7 @@ DataStream &operator<<(DataStream &stream, const PartMetaData &part)
return stream << part.d->name
<< part.d->size
<< part.d->version
<< part.d->external;
<< part.d->storageType;
}
DataStream &operator>>(DataStream &stream, PartMetaData &part)
......@@ -1188,7 +1190,7 @@ DataStream &operator>>(DataStream &stream, PartMetaData &part)
return stream >> part.d->name
>> part.d->size
>> part.d->version
>> part.d->external;
>> part.d->storageType;
}
/******************************************************************************/
......@@ -3205,7 +3207,13 @@ public:
Q_FOREACH (const StreamPayloadResponse &part, parts) {
blck.beginBlock(part.payloadName());
blck.write("Size", part.metaData().size());
blck.write("External", part.metaData().isExternal());
blck.write("External", [](PartMetaData::StorageType storage) {
switch (storage) {
case PartMetaData::Internal: return QStringLiteral("Internal");
case PartMetaData::External: return QStringLiteral("External");
case PartMetaData::Foreign: return QStringLiteral("Foreign");
}; Q_UNREACHABLE();
}(part.metaData().storageType()));
blck.write("Version", part.metaData().version());
blck.write("Data", part.data());
blck.endBlock();
......
......@@ -362,9 +362,15 @@ class PartMetaDataPrivate;
class AKONADIPRIVATE_EXPORT PartMetaData
{
public:
enum StorageType {
Internal,
External,
Foreign
};
explicit PartMetaData();
PartMetaData(const QByteArray &name, qint64 size, int version = 0,
bool external = false);
StorageType storageType = Internal);
PartMetaData(PartMetaData &&other);
PartMetaData(const PartMetaData &other);
~PartMetaData();
......@@ -386,8 +392,8 @@ public:
void setVersion(int version);
int version() const;
void setIsExternal(bool isExternal);
bool isExternal() const;
void setStorageType(StorageType storage);
StorageType storageType() const;
private:
QSharedDataPointer<PartMetaDataPrivate> d;
......
......@@ -48,7 +48,7 @@ bool Copy::copyItem(const PimItem &item, const Collection &target)
parts.reserve(item.parts().count());
Q_FOREACH (const Part &part, item.parts()) {
Part newPart(part);
newPart.setData(PartHelper::translateData(newPart.data(), part.external()));
newPart.setData(PartHelper::translateData(newPart.data(), part.storage()));
newPart.setPimItemId(-1);
parts << newPart;
}
......
......@@ -81,7 +81,7 @@ enum PartQueryColumns {
PartQueryPimIdColumn,
PartQueryTypeIdColumn,
PartQueryDataColumn,
PartQueryExternalColumn,
PartQueryStorageColumn,
PartQueryVersionColumn,
PartQueryDataSizeColumn
};
......@@ -96,7 +96,7 @@ QSqlQuery FetchHelper::buildPartQuery(const QVector<QByteArray> &partList, bool
partQuery.addColumn(PimItem::idFullColumnName());
partQuery.addColumn(Part::partTypeIdFullColumnName());
partQuery.addColumn(Part::dataFullColumnName());
partQuery.addColumn(Part::externalFullColumnName());
partQuery.addColumn(Part::storageFullColumnName());
partQuery.addColumn(Part::versionFullColumnName());
partQuery.addColumn(Part::datasizeFullColumnName());
......@@ -575,7 +575,8 @@ bool FetchHelper::fetchItems()
skipItem = true;
break;
}
metaPart.setIsExternal(partQuery.value(PartQueryExternalColumn).toBool());
metaPart.setStorageType(static_cast<Protocol::PartMetaData::StorageType>(
partQuery.value(PartQueryStorageColumn).toInt()));
if (data.isEmpty()) {
partData.setData(QByteArray(""));
} else {
......
......@@ -67,7 +67,7 @@
<comment>Contains the schema version of the database.</comment>
<column name="version" type="int" default="0" allowNull="false"/>
<column name="generation" type="int" default="0" allowNull="false" />
<data columns="version" values="34"/>
<data columns="version" values="35"/>
</table>
<table name="Resource">
......@@ -166,13 +166,17 @@
</table>
<table name="Part">
<enum name="Storage">
<value name="Internal"/>
<value name="External"/>
</enum>
<column name="id" type="qint64" allowNull="false" isAutoIncrement="true" isPrimaryKey="true"/>
<column name="pimItemId" type="qint64" refTable="PimItem" refColumn="id" allowNull="false"/>
<column name="partTypeId" type="qint64" refTable="PartType" refColumn="id" allowNull="false" noUpdate="true" />
<column name="data" type="QByteArray"/>
<column name="datasize" type="qint64" allowNull="false"/>
<column name="version" type="int" default="0"/>
<column name="external" type="bool" default="false" />
<column name="storage" type="enum" enumType="Part::Storage" default="Part::Internal"/>
<index name="pimItemIdTypeIndex" columns="pimItemId,partTypeId" unique="true"/>
<index name="pimItemIdSortIndex" columns="pimItemId" unique="false" sort="DESC"/>
</table>
......
......@@ -790,7 +790,7 @@ bool DataStore::cleanupCollection(Collection &collection)
qb.addJoin(QueryBuilder::InnerJoin, PimItem::tableName(), Part::pimItemIdFullColumnName(), PimItem::idFullColumnName());
qb.addJoin(QueryBuilder::InnerJoin, Collection::tableName(), PimItem::collectionIdFullColumnName(), Collection::idFullColumnName());
qb.addValueCondition(Collection::idFullColumnName(), Query::Equals, collection.id());
qb.addValueCondition(Part::externalFullColumnName(), Query::Equals, true);
qb.addValueCondition(Part::storageFullColumnName(), Query::Equals, Part::External);
qb.addValueCondition(Part::dataFullColumnName(), Query::IsNot, QVariant());
if (!qb.exec()) {
return false;
......
......@@ -320,4 +320,9 @@
<raw-sql backends="psql">SELECT setval('tagtypetable_id_seq', (SELECT max(id) FROM TagTypeTable))</raw-sql>
<raw-sql backends="psql">SELECT setval('relationtypetable_id_seq', (SELECT max(id) FROM RelationTypeTable))</raw-sql>
</update>
<update version="35" abortOnFailure="true">
<raw-sql backends="mysql,psql,sqlite">UPDATE PartTable SET storage = external;</raw-sql>
<raw-sql backends="mysql,psql,sqlite">ALTER TABLE PartTable DROP COLUMN external;</raw-sql>
</update>
</updates>
......@@ -398,7 +398,7 @@ void ItemRetriever::verifyCache()
SelectQueryBuilder<Part> qb;
qb.addJoin(QueryBuilder::InnerJoin, PimItem::tableName(), Part::pimItemIdFullColumnName(), PimItem::idFullColumnName());
qb.addValueCondition(Part::externalFullColumnName(), Query::Equals, true);
qb.addValueCondition(Part::storageFullColumnName(), Query::Equals, Part::External);
qb.addValueCondition(Part::dataFullColumnName(), Query::IsNot, QVariant());
if (mScope.scope() != Scope::Invalid) {
ItemQueryHelper::scopeToQuery(mScope, mConnection->context(), qb);
......
......@@ -42,24 +42,24 @@ void PartHelper::update(Part *part, const QByteArray &data, qint64 dataSize)
const bool storeExternal = dataSize > DbConfig::configuredDatabase()->sizeThreshold();
QByteArray newFile;
if (part->external() && storeExternal) {
if (part->storage() == Part::External && storeExternal) {
if (!ExternalPartStorage::self()->updatePartFile(data, part->data(), newFile)) {
throw PartHelperException(QStringLiteral("Failed to update external payload part"));
}
part->setData(newFile);
} else if (!part->external() && storeExternal) {
} else if (part->storage() != 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);
part->setStorage(Part::External);
} else {
if (part->external() && !storeExternal) {
if (part->storage() == Part::External && !storeExternal) {
const QString file = ExternalPartStorage::resolveAbsolutePath(part->data());
ExternalPartStorage::self()->removePartFile(file);
}
part->setData(data);
part->setExternal(false);
part->setStorage(Part::Internal);
}
part->setDatasize(dataSize);
......@@ -82,9 +82,9 @@ bool PartHelper::insert(Part *part, qint64 *insertId)
if (storeInFile) {
data = part->data();
part->setData(QByteArray());
part->setExternal(true);
part->setStorage(Part::External);
} else {
part->setExternal(false);
part->setStorage(Part::Internal);
}
bool result = part->insert(insertId);
......@@ -107,7 +107,7 @@ bool PartHelper::remove(Part *part)
return false;
}
if (part->external()) {
if (part->storage() == Part::External) {
ExternalPartStorage::self()->removePartFile(ExternalPartStorage::resolveAbsolutePath(part->data()));
}
return part->remove();
......@@ -117,7 +117,7 @@ bool PartHelper::remove(const QString &column, const QVariant &value)
{
SelectQueryBuilder<Part> builder;
builder.addValueCondition(column, Query::Equals, value);
builder.addValueCondition(Part::externalColumn(), Query::Equals, true);
builder.addValueCondition(Part::storageColumn(), Query::Equals, Part::External);
builder.addValueCondition(Part::dataColumn(), Query::IsNot, QVariant());
if (!builder.exec()) {
// qCDebug(AKONADISERVER_LOG) << "Error selecting records to be deleted from table"
......@@ -133,9 +133,9 @@ bool PartHelper::remove(const QString &column, const QVariant &value)
return Part::remove(column, value);
}
QByteArray PartHelper::translateData(const QByteArray &data, bool isExternal)
QByteArray PartHelper::translateData(const QByteArray &data, Part::Storage storage)
{
if (isExternal) {
if (storage == Part::External) {
const QString fileName = ExternalPartStorage::resolveAbsolutePath(data);
QFile file(fileName);
......@@ -156,24 +156,24 @@ QByteArray PartHelper::translateData(const QByteArray &data, bool isExternal)
QByteArray PartHelper::translateData(const Part &part)
{
return translateData(part.data(), part.external());
return translateData(part.data(), part.storage());
}
bool PartHelper::truncate(Part &part)
{
if (part.external()) {
if (part.storage() == Part::External) {
ExternalPartStorage::self()->removePartFile(ExternalPartStorage::resolveAbsolutePath(part.data()));
}
part.setData(QByteArray());
part.setDatasize(0);
part.setExternal(false);
part.setStorage(Part::Internal);
return part.update();
}
bool PartHelper::verify(Part &part)
{
if (!part.external()) {
if (part.storage() != Part::External) {
return true;
}
......@@ -182,7 +182,7 @@ bool PartHelper::verify(Part &part)
qCCritical(AKONADISERVER_LOG) << "Payload file" << fileName << "is missing, trying to recover.";
part.setData(QByteArray());
part.setDatasize(0);
part.setExternal(false);
part.setStorage(Part::Internal);
return part.update();
}
......
......@@ -64,7 +64,7 @@ bool remove(Part *part);
bool remove(const QString &column, const QVariant &value);
/** Returns the payload data. */
QByteArray translateData(const QByteArray &data, bool isExternal);
QByteArray translateData(const QByteArray &data, Part::Storage storageType);
/** Convenience overload of the above. */
QByteArray translateData(const Part &part);
......
......@@ -101,7 +101,7 @@ bool PartStreamer::streamPayload(Part &part, const QByteArray &partName)
bool PartStreamer::streamPayloadData(Part &part, const Protocol::PartMetaData &metaPart)
{
// If the part WAS external previously, remove data file
if (part.external()) {
if (part.storage() == Part::External) {
ExternalPartStorage::self()->removePartFile(
ExternalPartStorage::resolveAbsolutePath(part.data()));
}
......@@ -147,7 +147,7 @@ bool PartStreamer::streamPayloadToFile(Part &part, const Protocol::PartMetaData
QByteArray filename;
if (part.isValid()) {
if (part.external()) {
if (part.storage() == Part::External) {
// Part was external and is still external
filename = part.data();
ExternalPartStorage::self()->removePartFile(
......@@ -164,7 +164,7 @@ bool PartStreamer::streamPayloadToFile(Part &part, const Protocol::PartMetaData
}
}
part.setExternal(true);
part.setStorage(Part::External);
part.setDatasize(metaPart.size());
part.setData(filename);
......
......@@ -369,7 +369,7 @@ void StorageJanitor::findOverlappingParts()
QueryBuilder qb(Part::tableName(), QueryBuilder::Select);
qb.addColumn(Part::dataColumn());
qb.addColumn(QLatin1Literal("count(") + Part::idColumn() + QLatin1Literal(") as cnt"));
qb.addValueCondition(Part::externalColumn(), Query::Equals, true);
qb.addValueCondition(Part::storageColumn(), Query::Equals, Part::External);
qb.addValueCondition(Part::dataColumn(), Query::IsNot, QVariant());
qb.addGroupColumn(Part::dataColumn());
qb.addValueCondition(QLatin1Literal("count(") + Part::idColumn() + QLatin1Literal(")"), Query::Greater, 1, QueryBuilder::HavingCondition);
......@@ -410,7 +410,7 @@ void StorageJanitor::verifyExternalParts()
qb.addColumn(Part::dataColumn());
qb.addColumn(Part::pimItemIdColumn());
qb.addColumn(Part::idColumn());
qb.addValueCondition(Part::externalColumn(), Query::Equals, true);
qb.addValueCondition(Part::storageColumn(), Query::Equals, Part::External);
qb.addValueCondition(Part::dataColumn(), Query::IsNot, QVariant());
if (!qb.exec()) {
inform("Failed to query existing parts, skipping test");
......@@ -430,7 +430,7 @@ void StorageJanitor::verifyExternalParts()
part.setPimItemId(pimItemId);
part.setData(QByteArray());
part.setDatasize(0);
part.setExternal(false);
part.setStorage(Part::Internal);
part.update();
}
}
......@@ -572,7 +572,7 @@ void StorageJanitor::checkSizeTreshold()
{
QueryBuilder qb(Part::tableName(), QueryBuilder::Select);
qb.addColumn(Part::idFullColumnName());
qb.addValueCondition(Part::externalFullColumnName(), Query::Equals, false);
qb.addValueCondition(Part::storageFullColumnName(), Query::Equals, Part::Internal);
qb.addValueCondition(Part::datasizeFullColumnName(), Query::Greater, DbConfig::configuredDatabase()->sizeThreshold());
if (!qb.exec()) {
inform("Failed to query parts larger than treshold, skipping test");
......@@ -604,7 +604,7 @@ void StorageJanitor::checkSizeTreshold()
}
part.setData(name);
part.setExternal(true);
part.setStorage(Part::External);
if (!part.update() || !transaction.commit()) {
qCCritical(AKONADISERVER_LOG) << "Failed to update database entry of part" << part.id();
f.remove();
......@@ -618,7 +618,7 @@ void StorageJanitor::checkSizeTreshold()
{