sync: thread synckit DeviceId through the AF sync consumer
Completes the AF-side of synckit-client's DeviceId/UserId/AppId newtype
migration: `ensure_device_registered` returns `DeviceId`, and `push_changes`/
`pull_changes` take `DeviceId`, matching synckit's `push`/`pull` signatures.
Depends on the synckit DeviceId migration landing in MNW.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2 files changed,
+6 insertions,
-7 deletions
| 3 |
3 |
|
use std::path::Path;
|
| 4 |
4 |
|
|
| 5 |
5 |
|
use sha2::{Digest, Sha256};
|
| 6 |
|
- |
use synckit_client::SyncKitClient;
|
| 7 |
|
- |
use uuid::Uuid;
|
|
6 |
+ |
use synckit_client::{DeviceId, SyncKitClient};
|
| 8 |
7 |
|
|
| 9 |
8 |
|
use tracing::instrument;
|
| 10 |
9 |
|
|
| 263 |
262 |
|
pub(crate) async fn pull_changes(
|
| 264 |
263 |
|
db_path: &std::path::Path,
|
| 265 |
264 |
|
client: &SyncKitClient,
|
| 266 |
|
- |
device_id: Uuid,
|
|
265 |
+ |
device_id: DeviceId,
|
| 267 |
266 |
|
) -> Result<i64> {
|
| 268 |
267 |
|
let mut total_applied: i64 = 0;
|
| 269 |
268 |
|
|
| 2 |
2 |
|
|
| 3 |
3 |
|
use std::path::Path;
|
| 4 |
4 |
|
|
| 5 |
|
- |
use synckit_client::{ChangeEntry, ChangeOp, SyncKitClient};
|
|
5 |
+ |
use synckit_client::{ChangeEntry, ChangeOp, DeviceId, SyncKitClient};
|
| 6 |
6 |
|
use uuid::Uuid;
|
| 7 |
7 |
|
|
| 8 |
8 |
|
use tracing::instrument;
|
| 123 |
123 |
|
async fn ensure_device_registered(
|
| 124 |
124 |
|
db_path: &std::path::Path,
|
| 125 |
125 |
|
client: &SyncKitClient,
|
| 126 |
|
- |
) -> Result<Uuid> {
|
|
126 |
+ |
) -> Result<DeviceId> {
|
| 127 |
127 |
|
let p = db_path.to_path_buf();
|
| 128 |
128 |
|
let stored: String = tokio::task::spawn_blocking(move || {
|
| 129 |
129 |
|
let conn = open_conn(&p)?;
|
| 134 |
134 |
|
|
| 135 |
135 |
|
if !stored.is_empty()
|
| 136 |
136 |
|
&& let Ok(id) = stored.parse::<Uuid>() {
|
| 137 |
|
- |
return Ok(id);
|
|
137 |
+ |
return Ok(DeviceId::new(id));
|
| 138 |
138 |
|
}
|
| 139 |
139 |
|
|
| 140 |
140 |
|
let hostname = std::env::var("HOSTNAME")
|
| 164 |
164 |
|
async fn push_changes(
|
| 165 |
165 |
|
db_path: &std::path::Path,
|
| 166 |
166 |
|
client: &SyncKitClient,
|
| 167 |
|
- |
device_id: Uuid,
|
|
167 |
+ |
device_id: DeviceId,
|
| 168 |
168 |
|
) -> Result<i64> {
|
| 169 |
169 |
|
let p = db_path.to_path_buf();
|
| 170 |
170 |
|
let rows = tokio::task::spawn_blocking(move || -> Result<_> {
|