Skip to content

Commit 4086c0c

Browse files
committed
Remove sync15's "standalone-sync" feature, remove UDL for a single enum.
Remove the udl for sync15 - it just had one enum. "Bonus" update of the crate to 2024, which is a bigger diff than I anticipated. Seems ok though?
1 parent 32693fe commit 4086c0c

File tree

35 files changed

+94
-547
lines changed

35 files changed

+94
-547
lines changed

components/logins/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ default = []
1111
keydb = ["nss/keydb", "dep:async-trait", "dep:futures"]
1212

1313
[dependencies]
14-
# TODO: we've enabled the "standalone-sync" feature - see the description
15-
# of this feature in sync15's Cargo.toml for what we should do instead.
16-
sync15 = { path = "../sync15", features=["standalone-sync"] }
14+
sync15 = { path = "../sync15" }
1715
serde = "1"
1816
serde_derive = "1"
1917
serde_json = "1"

components/logins/src/error.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub use error_support::{debug, error, info, trace, warn};
1212

1313
use error_support::{ErrorHandling, GetErrorHandling};
1414
use jwcrypto::JwCryptoError;
15-
use sync15::Error as Sync15Error;
1615

1716
// Errors we return via the public interface.
1817
#[derive(Debug, thiserror::Error)]
@@ -50,9 +49,6 @@ pub enum LoginsApiError {
5049
#[error("{reason}")]
5150
Interrupted { reason: String },
5251

53-
#[error("SyncAuthInvalid error {reason}")]
54-
SyncAuthInvalid { reason: String },
55-
5652
#[error("Unexpected Error: {reason}")]
5753
UnexpectedLoginsApiError { reason: String },
5854
}
@@ -87,9 +83,6 @@ pub enum Error {
8783
#[error("decryption failed: {0:?}")]
8884
DecryptionFailed(String),
8985

90-
#[error("Error synchronizing: {0}")]
91-
SyncAdapterError(#[from] sync15::Error),
92-
9386
#[error("Error parsing JSON data: {0}")]
9487
JsonError(#[from] serde_json::Error),
9588

@@ -171,24 +164,6 @@ impl GetErrorHandling for Error {
171164
Self::Interrupted(_) => ErrorHandling::convert(LoginsApiError::Interrupted {
172165
reason: self.to_string(),
173166
}),
174-
Self::SyncAdapterError(e) => match e {
175-
Sync15Error::TokenserverHttpError(401) | Sync15Error::BadKeyLength(..) => {
176-
ErrorHandling::convert(LoginsApiError::SyncAuthInvalid {
177-
reason: e.to_string(),
178-
})
179-
.log_warning()
180-
}
181-
Sync15Error::RequestError(_) => {
182-
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
183-
reason: e.to_string(),
184-
})
185-
.log_warning()
186-
}
187-
_ => ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {
188-
reason: self.to_string(),
189-
})
190-
.report_error("logins-sync"),
191-
},
192167
Error::SqlError(rusqlite::Error::SqliteFailure(err, _)) => match err.code {
193168
rusqlite::ErrorCode::DatabaseCorrupt => {
194169
ErrorHandling::convert(LoginsApiError::UnexpectedLoginsApiError {

components/logins/src/logins.udl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ interface LoginsApiError {
146146
/// An operation was interrupted at the request of the consuming app.
147147
Interrupted(string reason);
148148

149-
/// Sync reported that authentication failed and the user should re-enter their FxA password.
150-
// TODO: remove this at the same time as remove the sync() method in favour of the SyncManager.
151-
SyncAuthInvalid(string reason);
152-
153149
/// something internal went wrong which doesn't have a public error value
154150
/// because the consuming app can not reasonably take any action to resolve it.
155151
/// The underlying error will have been logged and reported.

components/logins/src/schema.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@
7878
//! This table was added (by this rust crate) in version 4, and so is not
7979
//! present in firefox-ios.
8080
//!
81-
//! Currently it is used to store two items:
82-
//!
83-
//! 1. The last sync timestamp is stored under [LAST_SYNC_META_KEY], a
81+
//! Currently it is used to store the last sync timestamp, under [LAST_SYNC_META_KEY], a
8482
//! `sync15::ServerTimestamp` stored in integer milliseconds.
8583
//!
86-
//! 2. The persisted sync state machine information is stored under
87-
//! [GLOBAL_STATE_META_KEY]. This is a `sync15::GlobalState` stored as
88-
//! JSON.
89-
//!
9084
9185
use crate::error::*;
9286
use lazy_static::lazy_static;
@@ -197,7 +191,6 @@ const CREATE_DELETED_ORIGIN_INDEX_SQL: &str = "
197191
";
198192

199193
pub(crate) static LAST_SYNC_META_KEY: &str = "last_sync_time";
200-
pub(crate) static GLOBAL_STATE_META_KEY: &str = "global_state_v2";
201194
pub(crate) static GLOBAL_SYNCID_META_KEY: &str = "global_sync_id";
202195
pub(crate) static COLLECTION_SYNCID_META_KEY: &str = "passwords_sync_id";
203196
pub(crate) static CHECKPOINT_KEY: &str = "checkpoint";

components/logins/src/sync/engine.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -297,20 +297,6 @@ impl LoginsSyncEngine {
297297
Ok(Some(ServerTimestamp(millis)))
298298
}
299299

300-
pub fn set_global_state(&self, state: &Option<String>) -> Result<()> {
301-
let to_write = match state {
302-
Some(ref s) => s,
303-
None => "",
304-
};
305-
let db = self.store.lock_db()?;
306-
db.put_meta(schema::GLOBAL_STATE_META_KEY, &to_write)
307-
}
308-
309-
pub fn get_global_state(&self) -> Result<Option<String>> {
310-
let db = self.store.lock_db()?;
311-
db.get_meta::<String>(schema::GLOBAL_STATE_META_KEY)
312-
}
313-
314300
fn mark_as_synchronized(&self, guids: &[&str], ts: ServerTimestamp) -> Result<()> {
315301
let db = self.store.lock_db()?;
316302
let tx = db.unchecked_transaction()?;
@@ -378,7 +364,6 @@ impl LoginsSyncEngine {
378364
db.put_meta(schema::COLLECTION_SYNCID_META_KEY, &ids.coll)?;
379365
}
380366
};
381-
db.delete_meta(schema::GLOBAL_STATE_META_KEY)?;
382367
tx.commit()?;
383368
Ok(())
384369
}

components/places/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ exclude = ["/android", "/ios"]
1010
default = []
1111

1212
[dependencies]
13-
# TODO: we've enabled the "standalone-sync" feature - see the description
14-
# of this feature in sync15's Cargo.toml for what we should do instead.
15-
sync15 = { path = "../sync15", features=["standalone-sync"] }
13+
sync15 = { path = "../sync15" }
1614
serde = "1"
1715
serde_derive = "1"
1816
serde_json = "1"

components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -85,34 +85,6 @@ class PlacesApi(path: String) : PlacesManager, AutoCloseable {
8585
override fun close() {
8686
this.writeConn.apiRef.clear()
8787
}
88-
89-
override fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing {
90-
val pingJSONString = this.api.historySync(
91-
syncInfo.kid,
92-
syncInfo.fxaAccessToken,
93-
syncInfo.syncKey,
94-
syncInfo.tokenserverURL,
95-
)
96-
return SyncTelemetryPing.fromJSONString(pingJSONString)
97-
}
98-
99-
override fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing {
100-
val pingJSONString = this.api.bookmarksSync(
101-
syncInfo.kid,
102-
syncInfo.fxaAccessToken,
103-
syncInfo.syncKey,
104-
syncInfo.tokenserverURL,
105-
)
106-
return SyncTelemetryPing.fromJSONString(pingJSONString)
107-
}
108-
109-
override fun resetHistorySyncMetadata() {
110-
this.api.resetHistory()
111-
}
112-
113-
override fun resetBookmarkSyncMetadata() {
114-
return this.api.bookmarksReset()
115-
}
11688
}
11789

11890
@Suppress("TooGenericExceptionCaught")
@@ -530,50 +502,6 @@ interface PlacesManager {
530502
* This should always return the same object.
531503
*/
532504
fun getWriter(): WritableHistoryConnection
533-
534-
/**
535-
* Syncs the places history store, returning a telemetry ping.
536-
*
537-
* Note that this function blocks until the sync is complete, which may
538-
* take some time due to the network etc. Because only 1 thread can be
539-
* using a PlacesAPI at a time, it is recommended, but not enforced, that
540-
* you have all connections you intend using open before calling this.
541-
*/
542-
fun syncHistory(syncInfo: SyncAuthInfo): SyncTelemetryPing
543-
544-
/**
545-
* Syncs the places bookmarks store, returning a telemetry ping.
546-
*
547-
* Note that this function blocks until the sync is complete, which may
548-
* take some time due to the network etc. Because only 1 thread can be
549-
* using a PlacesAPI at a time, it is recommended, but not enforced, that
550-
* you have all connections you intend using open before calling this.
551-
*/
552-
fun syncBookmarks(syncInfo: SyncAuthInfo): SyncTelemetryPing
553-
554-
/**
555-
* Resets all sync metadata for history, including change flags,
556-
* sync statuses, and last sync time. The next sync after reset
557-
* will behave the same way as a first sync when connecting a new
558-
* device.
559-
*
560-
* This method only needs to be called when the user disconnects
561-
* from Sync. There are other times when Places resets sync metadata,
562-
* but those are handled internally in the Rust code.
563-
*/
564-
fun resetHistorySyncMetadata()
565-
566-
/**
567-
* Resets all sync metadata for bookmarks, including change flags,
568-
* sync statuses, and last sync time. The next sync after reset
569-
* will behave the same way as a first sync when connecting a new
570-
* device.
571-
*
572-
* This method only needs to be called when the user disconnects
573-
* from Sync. There are other times when Places resets sync metadata,
574-
* but those are handled internally in the Rust code.
575-
*/
576-
fun resetBookmarkSyncMetadata()
577505
}
578506

579507
interface InterruptibleConnection : AutoCloseable {

0 commit comments

Comments
 (0)