bool forceRemoteDiscovery = false;
SqlQuery versionQuery("SELECT major, minor, patch FROM version;", _db);
- if (!versionQuery.next()) {
+ if (!versionQuery.next().hasData) {
// If there was no entry in the table, it means we are likely upgrading from 1.5
qCInfo(lcDb) << "possibleUpgradeFromMirall_1_5 detected!";
forceRemoteDiscovery = true;
if (!query.exec()) {
return columns;
}
- while (query.next()) {
+ while (query.next().hasData) {
columns.append(query.baValue(1));
}
qCDebug(lcDb) << "Columns in the current journal: " << columns;
return false;
}
- if (_getFileRecordQuery.next()) {
+ auto next = _getFileRecordQuery.next();
+ if (!next.ok) {
+ QString err = _getFileRecordQuery.error();
+ qCWarning(lcDb) << "No journal entry found for " << filename << "Error: " << err;
+ close();
+ return false;
+ }
+ if (next.hasData) {
fillFileRecordFromGetQuery(*rec, _getFileRecordQuery);
- } else {
- int errId = _getFileRecordQuery.errorId();
- if (errId != SQLITE_DONE) { // only do this if the problem is different from SQLITE_DONE
- QString err = _getFileRecordQuery.error();
- qCWarning(lcDb) << "No journal entry found for " << filename << "Error: " << err;
- close();
- }
}
}
return true;
return false;
}
- if (_getFileRecordQueryByMangledName.next()) {
+ auto next = _getFileRecordQueryByMangledName.next();
+ if (!next.ok) {
+ QString err = _getFileRecordQueryByMangledName.error();
+ qCWarning(lcDb) << "No journal entry found for mangled name" << mangledName << "Error: " << err;
+ close();
+ return false;
+ }
+ if (next.hasData) {
fillFileRecordFromGetQuery(*rec, _getFileRecordQueryByMangledName);
- } else {
- int errId = _getFileRecordQueryByMangledName.errorId();
- if (errId != SQLITE_DONE) { // only do this if the problem is different from SQLITE_DONE
- QString err = _getFileRecordQueryByMangledName.error();
- qCWarning(lcDb) << "No journal entry found for mangled name" << mangledName << "Error: " << err;
- close();
- }
}
}
return true;
if (!_getFileRecordQueryByInode.exec())
return false;
- if (_getFileRecordQueryByInode.next())
+ auto next = _getFileRecordQueryByInode.next();
+ if (!next.ok)
+ return false;
+ if (next.hasData)
fillFileRecordFromGetQuery(*rec, _getFileRecordQueryByInode);
return true;
if (!_getFileRecordQueryByFileId.exec())
return false;
- while (_getFileRecordQueryByFileId.next()) {
+ forever {
+ auto next = _getFileRecordQueryByFileId.next();
+ if (!next.ok)
+ return false;
+ if (!next.hasData)
+ break;
+
SyncJournalFileRecord rec;
fillFileRecordFromGetQuery(rec, _getFileRecordQueryByFileId);
rowCallback(rec);
return false;
}
- while (query->next()) {
+ forever {
+ auto next = query->next();
+ if (!next.ok)
+ return false;
+ if (!next.hasData)
+ break;
+
SyncJournalFileRecord rec;
fillFileRecordFromGetQuery(rec, *query);
rowCallback(rec);
if (!_listFilesInPathQuery.exec())
return false;
- while (_listFilesInPathQuery.next()) {
+ forever {
+ auto next = _listFilesInPathQuery.next();
+ if (!next.ok)
+ return false;
+ if (!next.hasData)
+ break;
+
SyncJournalFileRecord rec;
fillFileRecordFromGetQuery(rec, _listFilesInPathQuery);
if (!rec._path.startsWith(path) || rec._path.indexOf("/", path.size() + 1) > 0) {
return -1;
}
- if (query.next()) {
+ if (query.next().hasData) {
int count = query.intValue(0);
return count;
}
return res;
}
- if (_getDownloadInfoQuery.next()) {
+ if (_getDownloadInfoQuery.next().hasData) {
toDownloadInfo(_getDownloadInfoQuery, &res);
- } else {
- res._valid = false;
}
}
return res;
QStringList superfluousPaths;
QVector<SyncJournalDb::DownloadInfo> deleted_entries;
- while (query.next()) {
+ while (query.next().hasData) {
const QString file = query.stringValue(3); // path
if (!keep.contains(file)) {
superfluousPaths.append(file);
if (!query.exec()) {
sqlFail("Count number of downloadinfo entries failed", query);
}
- if (query.next()) {
+ if (query.next().hasData) {
re = query.intValue(0);
}
}
return res;
}
- if (_getUploadInfoQuery.next()) {
+ if (_getUploadInfoQuery.next().hasData) {
bool ok = true;
res._chunk = _getUploadInfoQuery.intValue(0);
res._transferid = _getUploadInfoQuery.int64Value(1);
QStringList superfluousPaths;
- while (query.next()) {
+ while (query.next().hasData) {
const QString file = query.stringValue(0);
if (!keep.contains(file)) {
superfluousPaths.append(file);
_getErrorBlacklistQuery.reset_and_clear_bindings();
_getErrorBlacklistQuery.bindValue(1, file);
if (_getErrorBlacklistQuery.exec()) {
- if (_getErrorBlacklistQuery.next()) {
+ if (_getErrorBlacklistQuery.next().hasData) {
entry._lastTryEtag = _getErrorBlacklistQuery.baValue(0);
entry._lastTryModtime = _getErrorBlacklistQuery.int64Value(1);
entry._retryCount = _getErrorBlacklistQuery.intValue(2);
QStringList superfluousPaths;
- while (query.next()) {
+ while (query.next().hasData) {
const QString file = query.stringValue(0);
if (!keep.contains(file)) {
superfluousPaths.append(file);
if (!query.exec()) {
sqlFail("Count number of blacklist entries failed", query);
}
- if (query.next()) {
+ if (query.next().hasData) {
re = query.intValue(0);
}
}
return res;
}
- while (query.next()) {
+ while (query.next().hasData) {
PollInfo info;
info._file = query.stringValue(0);
info._modtime = query.int64Value(1);
*ok = false;
return result;
}
- while (_getSelectiveSyncListQuery.next()) {
+ forever {
+ auto next = _getSelectiveSyncListQuery.next();
+ if (!next.ok) {
+ *ok = false;
+ return result;
+ }
+ if (!next.hasData)
+ break;
+
auto entry = _getSelectiveSyncListQuery.stringValue(0);
if (!entry.endsWith(QLatin1Char('/'))) {
entry.append(QLatin1Char('/'));
return {};
query.bindValue(1, checksumTypeId);
if (!query.exec()) {
- return nullptr;
+ return QByteArray();
}
- if (!query.next()) {
+ if (!query.next().hasData) {
qCWarning(lcDb) << "No checksum type mapping found for" << checksumTypeId;
- return nullptr;
+ return QByteArray();
}
return query.baValue(0);
}
return 0;
}
- if (!_getChecksumTypeIdQuery.next()) {
+ if (!_getChecksumTypeIdQuery.next().hasData) {
qCWarning(lcDb) << "No checksum type mapping found for" << checksumType;
return 0;
}
return QByteArray();
}
- if (!_getDataFingerprintQuery.next()) {
+ if (!_getDataFingerprintQuery.next().hasData) {
return QByteArray();
}
return _getDataFingerprintQuery.baValue(0);
ASSERT(query.initOrReset(QByteArrayLiteral("SELECT baseFileId, baseModtime, baseEtag, basePath FROM conflicts WHERE path=?1;"), _db));
query.bindValue(1, path);
ASSERT(query.exec());
- if (!query.next())
+ if (!query.next().hasData)
return entry;
entry.path = path;
ASSERT(query.exec());
QByteArrayList paths;
- while (query.next())
+ while (query.next().hasData)
paths.append(query.baValue(0));
return paths;
query.bindValue(1, path);
query.exec();
+ auto next = query.next();
+ if (!next.ok)
+ return {};
// no-entry means Inherited
- if (!query.next())
+ if (!next.hasData)
return PinState::Inherited;
return static_cast<PinState>(query.intValue(0));
query.bindValue(1, path);
query.exec();
+ auto next = query.next();
+ if (!next.ok)
+ return {};
// If the root path has no setting, assume AlwaysLocal
- if (!query.next())
+ if (!next.hasData)
return PinState::AlwaysLocal;
return static_cast<PinState>(query.intValue(0));
query.exec();
QVector<QPair<QByteArray, PinState>> result;
- while (query.next()) {
+ forever {
+ auto next = query.next();
+ if (!next.ok)
+ return {};
+ if (!next.hasData)
+ break;
result.append({ query.baValue(0), static_cast<PinState>(query.intValue(1)) });
}
return result;