1
0
Fork 0

NavCache: fix writes to a read-only DB

When in read-only mode, we were still allowing writes during the
octree building, which is bad. Add the missing check.

Sentry-Id: FLIGHTGEAR-8F
This commit is contained in:
James Turner 2020-10-29 21:13:47 +00:00
parent 4075ea02e9
commit e028c52e42

View file

@ -265,7 +265,7 @@ public:
}
int openFlags = readOnly ? SQLITE_OPEN_READONLY :
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
(SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
std::string pathUtf8 = path.utf8Str();
int result = sqlite3_open_v2(pathUtf8.c_str(), &db, openFlags, NULL);
if (result == SQLITE_MISUSE) {
@ -2032,6 +2032,10 @@ int NavDataCache::getOctreeBranchChildren(int64_t octreeNodeId)
void NavDataCache::defineOctreeNode(Octree::Branch* pr, Octree::Node* nd)
{
if (isReadOnly()) {
return;
}
sqlite3_bind_int64(d->insertOctree, 1, nd->guid());
d->execInsert(d->insertOctree);