1
0
Fork 0

NavDataCache: do not write to db in read-only mode

This commit is contained in:
Richard Harrison 2018-09-15 18:05:57 +02:00
parent 3889af3170
commit 4eaeb594ab

View file

@ -628,6 +628,7 @@ public:
void writeIntProperty(const string& key, int value) void writeIntProperty(const string& key, int value)
{ {
if (!readOnly){
sqlite_bind_stdstring(clearProperty, 1, key); sqlite_bind_stdstring(clearProperty, 1, key);
execUpdate(clearProperty); execUpdate(clearProperty);
@ -635,6 +636,7 @@ public:
sqlite3_bind_int(writePropertyQuery, 2, value); sqlite3_bind_int(writePropertyQuery, 2, value);
execUpdate(writePropertyQuery); execUpdate(writePropertyQuery);
} }
}
FGPositioned* loadById(sqlite_int64 rowId, sqlite3_int64& aptId); FGPositioned* loadById(sqlite_int64 rowId, sqlite3_int64& aptId);
@ -1554,6 +1556,7 @@ void NavDataCache::writeIntProperty(const string& key, int value)
void NavDataCache::writeStringProperty(const string& key, const string& value) void NavDataCache::writeStringProperty(const string& key, const string& value)
{ {
if (!isReadOnly()) {
sqlite_bind_stdstring(d->clearProperty, 1, key); sqlite_bind_stdstring(d->clearProperty, 1, key);
d->execUpdate(d->clearProperty); d->execUpdate(d->clearProperty);
@ -1561,9 +1564,11 @@ void NavDataCache::writeStringProperty(const string& key, const string& value)
sqlite_bind_stdstring(d->writePropertyQuery, 2, value); sqlite_bind_stdstring(d->writePropertyQuery, 2, value);
d->execUpdate(d->writePropertyQuery); d->execUpdate(d->writePropertyQuery);
} }
}
void NavDataCache::writeDoubleProperty(const string& key, const double& value) void NavDataCache::writeDoubleProperty(const string& key, const double& value)
{ {
if (!isReadOnly()) {
sqlite_bind_stdstring(d->clearProperty, 1, key); sqlite_bind_stdstring(d->clearProperty, 1, key);
d->execUpdate(d->clearProperty); d->execUpdate(d->clearProperty);
@ -1571,6 +1576,7 @@ void NavDataCache::writeDoubleProperty(const string& key, const double& value)
sqlite3_bind_double(d->writePropertyQuery, 2, value); sqlite3_bind_double(d->writePropertyQuery, 2, value);
d->execUpdate(d->writePropertyQuery); d->execUpdate(d->writePropertyQuery);
} }
}
string_list NavDataCache::readStringListProperty(const string& key) string_list NavDataCache::readStringListProperty(const string& key)
{ {
@ -1586,6 +1592,7 @@ string_list NavDataCache::readStringListProperty(const string& key)
void NavDataCache::writeStringListProperty(const string& key, const string_list& values) void NavDataCache::writeStringListProperty(const string& key, const string_list& values)
{ {
if (!isReadOnly()) {
sqlite_bind_stdstring(d->clearProperty, 1, key); sqlite_bind_stdstring(d->clearProperty, 1, key);
d->execUpdate(d->clearProperty); d->execUpdate(d->clearProperty);
@ -1595,6 +1602,7 @@ void NavDataCache::writeStringListProperty(const string& key, const string_list&
d->execInsert(d->writePropertyMulti); d->execInsert(d->writePropertyMulti);
} }
} }
}
string_list NavDataCache::readOrderedStringListProperty(const string& key, string_list NavDataCache::readOrderedStringListProperty(const string& key,
const char* separator) const char* separator)
@ -1635,10 +1643,12 @@ bool NavDataCache::isCachedFileModified(const SGPath& path) const
void NavDataCache::stampCacheFile(const SGPath& path) void NavDataCache::stampCacheFile(const SGPath& path)
{ {
if (!isReadOnly()){
sqlite_bind_temp_stdstring(d->stampFileCache, 1, path.realpath().utf8Str()); sqlite_bind_temp_stdstring(d->stampFileCache, 1, path.realpath().utf8Str());
sqlite3_bind_int64(d->stampFileCache, 2, path.modTime()); sqlite3_bind_int64(d->stampFileCache, 2, path.modTime());
d->execInsert(d->stampFileCache); d->execInsert(d->stampFileCache);
} }
}
void NavDataCache::beginTransaction() void NavDataCache::beginTransaction()
{ {