api: retry twice for insert
This commit is contained in:
parent
bcde7ca74a
commit
fd9b1310b0
|
@ -173,11 +173,16 @@ fn items_sync(db: DbConn, u: user::User, params: Json<SyncParams>) -> Custom<Jso
|
|||
|
||||
// First, update all items sent by client
|
||||
for it in inner_params.items.into_iter() {
|
||||
if let Err(item::ItemOpError(_)) = item::SyncItem::items_insert(&db, &u, &it) {
|
||||
// Well, we should try twice...
|
||||
// TODO: make this more elegant (also handle differneces between db error and conflict)
|
||||
// (if we were ever to implement a conflict feature)
|
||||
if let Err(item::ItemOpError(_)) = item::SyncItem::items_insert(&db, &u, &it) {
|
||||
// Let's not fail just because one of them...
|
||||
// At least the client will know there's an error
|
||||
// (maybe mistakes it for conflict)
|
||||
resp.unsaved.push(it);
|
||||
}
|
||||
} else {
|
||||
resp.saved_items.push(it);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue