Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
dev:web_api:v3:syncing [2019/03/10 04:22] – [Full-Library Syncing] dstillman | dev:web_api:v3:syncing [2019/03/10 04:38] – dstillman | ||
---|---|---|---|
Line 14: | Line 14: | ||
* A version number for each library | * A version number for each library | ||
* A version number and a boolean '' | * A version number and a boolean '' | ||
+ | * A flag indicating that a downloaded object could not be processed and should be requested explicitly regardless of its remote version number (optional; see [[#Handling save errors|Handling save errors]] for details) | ||
===== Version Numbers ===== | ===== Version Numbers ===== | ||
Line 68: | Line 69: | ||
Like '' | Like '' | ||
+ | |||
+ | === Local object versions === | ||
+ | |||
+ | The use of local object versions during syncing, and the process for updating them, is described below. | ||
+ | |||
+ | When objects are created or modified locally by the user during regular usage, set '' | ||
===== Full-Library Syncing ===== | ===== Full-Library Syncing ===== | ||
Line 139: | Line 146: | ||
Retrieve the versions of all objects changed since the last check for that object type, using the appropriate request for each object type: | Retrieve the versions of all objects changed since the last check for that object type, using the appropriate request for each object type: | ||
- | GET < | + | GET < |
- | GET < | + | GET < |
- | GET < | + | GET < |
- | GET < | + | GET < |
- | ''< | + | ''< |
(The '' | (The '' | ||
Line 162: | Line 169: | ||
For each returned object, compare the version to the local version of the object. If the remote version doesn' | For each returned object, compare the version to the local version of the object. If the remote version doesn' | ||
- | Retrieve the queued objects by key, up to 50 at a time, using the appropriate request for each object type: | + | Retrieve the queued objects, as well as any [[#Handling save errors|flagged]] as having previously failed to save, by key, up to 50 at a time, using the appropriate request for each object type: |
GET < | GET < | ||
Line 197: | Line 204: | ||
| | ||
- | If an error occurs while processing an object (e.g., due to a foreign-key constraint in a database), it can be handled one of two ways: | + | == Handling save errors == |
+ | |||
+ | If an error occurs while processing an object (e.g., due to a foreign-key constraint in the local database), it can be handled one of two ways: | ||
- Treat the error as fatal and stop the sync without updating the local library version | - Treat the error as fatal and stop the sync without updating the local library version | ||
Line 203: | Line 212: | ||
When processing a set of objects, it may be helpful to maintain an object queue and add failing objects to the end of the queue in case they depend on other objects to succeed. (In some cases, it's also possible to sort objects beforehand to avoid such errors, such as by sorting parent collections before subcollections.) | When processing a set of objects, it may be helpful to maintain an object queue and add failing objects to the end of the queue in case they depend on other objects to succeed. (In some cases, it's also possible to sort objects beforehand to avoid such errors, such as by sorting parent collections before subcollections.) | ||
- | |||
- | When objects are created or modified locally by the user during regular usage, set '' | ||
=== ii. Get deleted data === | === ii. Get deleted data === | ||
GET < | GET < | ||
+ | |||
+ | ''< | ||
Response: | Response: | ||
Line 243: | Line 252: | ||
else: | else: | ||
perform conflict resolution | perform conflict resolution | ||
+ | if user chooses deletion, delete local object, skipping delete log | ||
| | ||
- | if user chooses deletion, delete local object, skipping delete log | + | |
- | + | ||
- | | + | |
Tags removed from all items are not necessarily deleted, hence the separate tag deletion mechanism. | Tags removed from all items are not necessarily deleted, hence the separate tag deletion mechanism. | ||
Line 284: | Line 292: | ||
On a '' | On a '' | ||
- | |||
===== Partial-Library Syncing ===== | ===== Partial-Library Syncing ===== |