-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Prepare for more DefaultFileSource changes #12072
Conversation
} | ||
|
||
} // namespace | ||
|
||
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) { | ||
using namespace mbgl; | ||
class OfflineDatabaseTest : public ::testing::Test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dislike the "fixture" style of testing -- it makes it non-obvious what tests do, because they have hidden behavior without even an obvious function call you can trace through. Can we stick to the existing style?
src/mbgl/util/logging.cpp
Outdated
@@ -43,8 +43,7 @@ void Log::record(EventSeverity severity, Event event, int64_t code) { | |||
} | |||
|
|||
void Log::record(EventSeverity severity, Event event, int64_t code, const std::string &msg) { | |||
if (currentObserver && severity != EventSeverity::Debug && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there a reason this was skipping Debug
severity before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really; we aren't using Debug much. I changed the logging of one expected message from Debug to Info since it was a better fit anyway.
platform/default/sqlite3.cpp
Outdated
@@ -190,25 +187,46 @@ Database &Database::operator=(Database &&other) { | |||
|
|||
Database::~Database() = default; | |||
|
|||
|
|||
DatabaseImpl::~DatabaseImpl() { | |||
// Mark all transactions as invalid by removing the pointer to the database |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does this situation arise? Do we not want it to be considered a logic error, and require the database to outlive any transactions?
137a039
to
792dea4
Compare
Please re-review; I split up all of the commits to make them easier to review. I removed the common base class for tests, and they now explicitly perform all preparatory actions in each test body. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch on the Transaction
/Database
move interaction.
switch (userVersion()) { | ||
case 0: | ||
case 1: | ||
// cache-only database; remove old table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Newly created database, or old cache-only database; remove old table if it exists.
Before this change, we've tried to open the database in read/write, but not create mode. In situations where the database didn't exist yet, this logged an error to the console, and we proceeded to opening it again in read/write/create mode, which actually created the file. The reason we did this is so that we could detect really old caching databases from January 2016 in case a developer upgraded from an older SDK (iOS v3.1 and earlier, Android v3.2 and earlier) that didn't have #3715 yet. However, these error messages, while innocent, look scary in the console and some users suspect that it's a bug. This change opens the file directly in read/write/create mode, omitting the first failed attempt. To handle old cache databases, we're now deleting the `http_cache` table, which was the only table in those old databases, and create the new schema, rather than deleting the entire file and recreating the Database object. In most scenarios, this will lead to one fewer opening attempt, while the database migration will continue to work for the few users who upgrade all the way from a January 2016 SDK. Additionally, this fixes a mismatch between the Qt and non-Qt implementation: Qt doesn't support opening a file in read/write mode without the create flag. This means that we've seen a different control flow on Qt compared to the non-Qt implementation when opening a database.
🎉 |
No description provided.