Signal-iOS/SignalServiceKit
Evan Hahn d36a7f58c0 Handle SQLite corruption during database migration, take 2
I recommend reviewing this with whitespace changes disabled.

If a database migration fails, we want to do two things:

1. Check if it failed due to database corruption. If so, flag the
   database as corrupted to enable recovery.
2. Crash.

We were only doing the second part because each individual migration
would crash instead of throwing the error.

The logic was effectively this:

    do {
      for migration in migrations {
        do {
          try migration.run()
        } catch {
          crash()
        }
      }
    } catch {
      // This `catch` would never happen because a failed migration
      // would crash, not throw.
      flagDatabaseCorruptionIfNecessary(error)
      crash()
    }

Now it's this:

    do {
      for migration in migrations {
        try migration.run()
      }
    } catch {
      flagDatabaseCorruptionIfNecessary(error)
      crash()
    }

See 3892b9ead6, which was my first attempt
at doing this.

Also see <https://github.com/signalapp/Signal-iOS/issues/5481> for
people experiencing this issue.
2023-01-27 14:05:28 -06:00
..
Experience Upgrades Refactor contact access code 2023-01-12 09:55:30 -08:00
Jobs Add all JobQueues to environment, via a wrapper 2022-11-09 14:08:44 -06:00
protobuf Add spam reporting tokens 2023-01-25 14:14:57 -06:00
Resources Add spam reporting tokens 2023-01-25 14:14:57 -06:00
src Handle SQLite corruption during database migration, take 2 2023-01-27 14:05:28 -06:00
tests Clean up "set subscriber ID" request 2023-01-26 13:45:25 -06:00
.clang-format Update clang-format with AllowShortEnumsOnASingleLine: false 2022-03-14 11:20:20 -07:00
.gitignore
.travis.yml
SignalServiceKit-Prefix.pch Change license to AGPL 2022-10-13 08:25:37 -05:00
SignalServiceKit.h Call Disposition 2023-01-10 11:48:46 -08:00