Akonadi: handle 404 in readItem()

readItem() might be asked to retrieve a non-existent item.
The fetch job succeeds in that case, but without returning
any item. Throw the 404 status error in this case.
This commit is contained in:
Patrick Ohly 2012-01-31 13:24:09 +00:00
parent 4928d51eca
commit f2cb364e23
1 changed files with 3 additions and 0 deletions

View File

@ -225,6 +225,9 @@ void AkonadiSyncSource::readItem(const std::string &luid, std::string &data, boo
ItemFetchJob *fetchJob = new ItemFetchJob(Item(syncItemId));
fetchJob->fetchScope().fetchFullPayload();
if (fetchJob->exec()) {
if (fetchJob->items().empty()) {
throwError(STATUS_NOT_FOUND, string("extracting item ") + luid);
}
QByteArray payload = fetchJob->items().first().payloadData();
data.assign(payload.constData(),
payload.size());