Skip to content

Commit

Permalink
Merge pull request #1304 from mozilla/no-expect-places-drop
Browse files Browse the repository at this point in the history
Avoid panicing when closing places db.
  • Loading branch information
Thom Chiovoloni committed Jun 14, 2019
2 parents 12880b7 + 648294d commit 15ea0ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGES_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
# Unreleased Changes

[Full Changelog](https://github.com/mozilla/application-services/compare/v0.31.2...master)

## Places

### What's fixed

- Fix an error that could happen when the place database is closed.
([#1304](https://github.com/mozilla/application-services/pull/1304))

- iOS only: Ensure interruption errors don't come through as network errors.
([#1304](https://github.com/mozilla/application-services/pull/1304))
4 changes: 2 additions & 2 deletions components/logins/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ pub mod error_codes {
/// A request to the sync server failed.
pub const NETWORK: i32 = 6;

/// A request to the sync server failed.
pub const INTERRUPTED: i32 = 6;
/// An operation has been interrupted.
pub const INTERRUPTED: i32 = 7;
}

fn get_code(err: &Error) -> ErrorCode {
Expand Down
7 changes: 4 additions & 3 deletions components/places/src/db/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ impl Drop for PlacesDb {
fn drop(&mut self) {
// In line with both the recommendations from SQLite and the behavior of places in
// Database.cpp, we run `PRAGMA optimize` before closing the connection.
self.db
.execute_batch("PRAGMA optimize(0x02);")
.expect("PRAGMA optimize should always succeed!");
let res = self.db.execute_batch("PRAGMA optimize(0x02);");
if let Err(e) = res {
log::warn!("Failed to execute pragma optimize (DB locked?): {}", e);
}
}
}

Expand Down

0 comments on commit 15ea0ec

Please sign in to comment.