Allow to skip the device/get_status call when calling folder_tree_update

- this is useful to safe one extra call when it is known that there
   should be changes on the remote. In that case it will immediately
   skip forward to calling device/get_changes
This commit is contained in:
josch
2014-12-04 16:21:39 +01:00
parent 71f6396a9a
commit 816d79438f
4 changed files with 22 additions and 15 deletions

View File

@@ -1376,8 +1376,12 @@ static int folder_tree_update_folder_info(folder_tree * tree, mfconn * conn,
* ask the remote if there are changes after the locally stored revision
*
* if yes, integrate those changes
*
* the expect_changes parameter allows to skip the call to device/get_status
* because sometimes one knows that there should be a remote change, so it is
* useless to waste time on the additional call
*/
void folder_tree_update(folder_tree * tree, mfconn * conn)
void folder_tree_update(folder_tree * tree, mfconn * conn, bool expect_changes)
{
uint64_t revision_remote;
uint64_t i;
@@ -1387,12 +1391,14 @@ void folder_tree_update(folder_tree * tree, mfconn * conn)
const char *key;
uint64_t revision;
mfconn_api_device_get_status(conn, &revision_remote);
mfconn_update_secret_key(conn);
if (!expect_changes) {
mfconn_api_device_get_status(conn, &revision_remote);
mfconn_update_secret_key(conn);
if (tree->revision == revision_remote) {
fprintf(stderr, "Request to update but nothing to do\n");
return;
if (tree->revision == revision_remote) {
fprintf(stderr, "Request to update but nothing to do\n");
return;
}
}
/*
@@ -1558,7 +1564,7 @@ int folder_tree_rebuild(folder_tree * tree, mfconn * conn)
* call device/get_changes to get possible remote changes while we walked
* the tree.
*/
folder_tree_update(tree, conn);
folder_tree_update(tree, conn, false);
return 0;
}