From 73123d87e9f3491e4bdd50efa4b811e53d1ac339 Mon Sep 17 00:00:00 2001 From: josch Date: Fri, 5 Dec 2014 14:02:33 +0100 Subject: [PATCH] move mfconn_update_secret_key into the apicalls --- fuse/filecache.c | 3 --- fuse/hashtbl.c | 7 ------- fuse/operations.c | 4 ---- mfapi/apicalls/device_get_changes.c | 1 + mfapi/apicalls/device_get_patch.c | 1 + mfapi/apicalls/device_get_status.c | 1 + mfapi/apicalls/device_get_updates.c | 1 + mfapi/apicalls/file_delete.c | 1 + mfapi/apicalls/file_get_info.c | 1 + mfapi/apicalls/file_get_links.c | 1 + mfapi/apicalls/folder_create.c | 1 + mfapi/apicalls/folder_delete.c | 1 + mfapi/apicalls/folder_get_content.c | 1 + mfapi/apicalls/folder_get_info.c | 1 + mfapi/apicalls/upload_simple.c | 1 + mfapi/apicalls/user_get_info.c | 1 + mfshell/commands/changes.c | 1 - mfshell/commands/chdir.c | 1 - mfshell/commands/file.c | 1 - mfshell/commands/folder.c | 1 - mfshell/commands/get.c | 2 -- mfshell/commands/links.c | 1 - mfshell/commands/list.c | 2 -- mfshell/commands/mkdir.c | 1 - mfshell/commands/put.c | 1 - mfshell/commands/rm.c | 1 - mfshell/commands/rmdir.c | 1 - mfshell/commands/status.c | 1 - mfshell/commands/updates.c | 1 - mfshell/commands/whoami.c | 1 - 30 files changed, 13 insertions(+), 30 deletions(-) diff --git a/fuse/filecache.c b/fuse/filecache.c index 13c88bc..675c8ff 100644 --- a/fuse/filecache.c +++ b/fuse/filecache.c @@ -136,7 +136,6 @@ static int filecache_download_file(const char *filecache_path, file = file_alloc(); retval = mfconn_api_file_get_links(conn, file, (char *)quickkey); - mfconn_update_secret_key(conn); if (retval == -1) { fprintf(stderr, "mfconn_api_file_get_links failed\n"); @@ -187,7 +186,6 @@ static int filecache_update_file(const char *filecache_path, mfconn * conn, retval = mfconn_api_device_get_updates(conn, quickkey, local_revision, remote_revision, &patches); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "device/get_updates api call unsuccessful\n"); @@ -305,7 +303,6 @@ static int filecache_download_patch(mfconn * conn, const char *quickkey, patch = patch_alloc(); retval = mfconn_api_device_get_patch(conn, patch, quickkey, source_revision, target_revision); - mfconn_update_secret_key(conn); if (retval == -1) { fprintf(stderr, "mfconn_api_device_get_patch failed\n"); diff --git a/fuse/hashtbl.c b/fuse/hashtbl.c index cc8a30c..c1d5339 100644 --- a/fuse/hashtbl.c +++ b/fuse/hashtbl.c @@ -1076,7 +1076,6 @@ static int folder_tree_rebuild_helper(folder_tree * tree, mfconn * conn, retval = mfconn_api_folder_get_content(conn, 0, curr_entry->key, &folder_result, NULL); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "folder/get_content failed\n"); if (folder_result != NULL) { @@ -1105,7 +1104,6 @@ static int folder_tree_rebuild_helper(folder_tree * tree, mfconn * conn, retval = mfconn_api_folder_get_content(conn, 1, curr_entry->key, NULL, &file_result); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "folder/get_content failed\n"); if (file_result != NULL) { @@ -1270,7 +1268,6 @@ static int folder_tree_update_file_info(folder_tree * tree, mfconn * conn, file = file_alloc(); retval = mfconn_api_file_get_info(conn, file, key); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "api call unsuccessful\n"); /* maybe there is a different reason but for now just assume that an @@ -1332,7 +1329,6 @@ static int folder_tree_update_folder_info(folder_tree * tree, mfconn * conn, folder = folder_alloc(); retval = mfconn_api_folder_get_info(conn, folder, key); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "api call unsuccessful\n"); /* maybe there is a different reason but for now just assume that an @@ -1393,7 +1389,6 @@ void folder_tree_update(folder_tree * tree, mfconn * conn, bool expect_changes) 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"); @@ -1419,7 +1414,6 @@ void folder_tree_update(folder_tree * tree, mfconn * conn, bool expect_changes) changes = NULL; retval = mfconn_api_device_get_changes(conn, tree->revision, &changes); - mfconn_update_secret_key(conn); if (retval != 0) { fprintf(stderr, "device/get_changes() failed\n"); free(changes); @@ -1542,7 +1536,6 @@ int folder_tree_rebuild(folder_tree * tree, mfconn * conn) /* get remote device revision before walking the tree */ ret = mfconn_api_device_get_status(conn, &revision_before); - mfconn_update_secret_key(conn); if (ret != 0) { fprintf(stderr, "device/get_status call unsuccessful\n"); return -1; diff --git a/fuse/operations.c b/fuse/operations.c index c75b9ad..a433ee7 100644 --- a/fuse/operations.c +++ b/fuse/operations.c @@ -220,7 +220,6 @@ int mediafirefs_mkdir(const char *path, mode_t mode) } retval = mfconn_api_folder_create(ctx->conn, key, basename); - mfconn_update_secret_key(ctx->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_folder_create unsuccessful\n"); // FIXME: find better errno in this case @@ -257,7 +256,6 @@ int mediafirefs_rmdir(const char *path) } retval = mfconn_api_folder_delete(ctx->conn, key); - mfconn_update_secret_key(ctx->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_folder_create unsuccessful\n"); // FIXME: find better errno in this case @@ -293,7 +291,6 @@ int mediafirefs_unlink(const char *path) } retval = mfconn_api_file_delete(ctx->conn, key); - mfconn_update_secret_key(ctx->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_file_create unsuccessful\n"); // FIXME: find better errno in this case @@ -431,7 +428,6 @@ int mediafirefs_release(const char *path, struct fuse_file_info *file_info) retval = mfconn_api_upload_simple(ctx->conn, folder_key, fh, file_name, &upload_key); - mfconn_update_secret_key(ctx->conn); fclose(fh); free(temp1); diff --git a/mfapi/apicalls/device_get_changes.c b/mfapi/apicalls/device_get_changes.c index baa2d12..bf02417 100644 --- a/mfapi/apicalls/device_get_changes.c +++ b/mfapi/apicalls/device_get_changes.c @@ -57,6 +57,7 @@ int mfconn_api_device_get_changes(mfconn * conn, uint64_t revision, http_get_buf(http, api_call, _decode_device_get_changes, (void *)changes); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/device_get_patch.c b/mfapi/apicalls/device_get_patch.c index 71c9c6f..3438c94 100644 --- a/mfapi/apicalls/device_get_patch.c +++ b/mfapi/apicalls/device_get_patch.c @@ -65,6 +65,7 @@ int mfconn_api_device_get_patch(mfconn * conn, mfpatch * patch, retval = http_get_buf(http, api_call, _decode_device_get_patch, (void *)patch); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/device_get_status.c b/mfapi/apicalls/device_get_status.c index 3c9896c..d999430 100644 --- a/mfapi/apicalls/device_get_status.c +++ b/mfapi/apicalls/device_get_status.c @@ -48,6 +48,7 @@ int mfconn_api_device_get_status(mfconn * conn, uint64_t * revision) http_get_buf(http, api_call, _decode_device_get_status, (void *)revision); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/device_get_updates.c b/mfapi/apicalls/device_get_updates.c index 548deff..5610879 100644 --- a/mfapi/apicalls/device_get_updates.c +++ b/mfapi/apicalls/device_get_updates.c @@ -73,6 +73,7 @@ int mfconn_api_device_get_updates(mfconn * conn, const char *quickkey, retval = http_get_buf(http, api_call, _decode_device_get_updates, (void *)patches); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/file_delete.c b/mfapi/apicalls/file_delete.c index dcca305..d3aa607 100644 --- a/mfapi/apicalls/file_delete.c +++ b/mfapi/apicalls/file_delete.c @@ -47,6 +47,7 @@ int mfconn_api_file_delete(mfconn * conn, const char *quickkey) http = http_create(); retval = http_get_buf(http, api_call, mfapi_decode_common, "file/delete"); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/file_get_info.c b/mfapi/apicalls/file_get_info.c index 5f90252..3a30ae3 100644 --- a/mfapi/apicalls/file_get_info.c +++ b/mfapi/apicalls/file_get_info.c @@ -61,6 +61,7 @@ int mfconn_api_file_get_info(mfconn * conn, mffile * file, http = http_create(); retval = http_get_buf(http, api_call, _decode_file_get_info, file); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/file_get_links.c b/mfapi/apicalls/file_get_links.c index 3bf8547..9cc41fe 100644 --- a/mfapi/apicalls/file_get_links.c +++ b/mfapi/apicalls/file_get_links.c @@ -59,6 +59,7 @@ int mfconn_api_file_get_links(mfconn * conn, mffile * file, http = http_create(); retval = http_get_buf(http, api_call, _decode_file_get_links, file); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/folder_create.c b/mfapi/apicalls/folder_create.c index 743ca69..5674840 100644 --- a/mfapi/apicalls/folder_create.c +++ b/mfapi/apicalls/folder_create.c @@ -61,6 +61,7 @@ int mfconn_api_folder_create(mfconn * conn, const char *parent, retval = http_get_buf(http, api_call, mfapi_decode_common, "folder/create"); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/folder_delete.c b/mfapi/apicalls/folder_delete.c index 83cddcf..2210f4a 100644 --- a/mfapi/apicalls/folder_delete.c +++ b/mfapi/apicalls/folder_delete.c @@ -48,6 +48,7 @@ int mfconn_api_folder_delete(mfconn * conn, const char *folderkey) retval = http_get_buf(http, api_call, mfapi_decode_common, "folder/delete"); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/folder_get_content.c b/mfapi/apicalls/folder_get_content.c index 888ff94..4bb7f8c 100644 --- a/mfapi/apicalls/folder_get_content.c +++ b/mfapi/apicalls/folder_get_content.c @@ -89,6 +89,7 @@ mfconn_api_folder_get_content(mfconn * conn, int mode, const char *folderkey, _decode_folder_get_content_files, (void *)mffile_result); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/folder_get_info.c b/mfapi/apicalls/folder_get_info.c index 453e18f..1d038ca 100644 --- a/mfapi/apicalls/folder_get_info.c +++ b/mfapi/apicalls/folder_get_info.c @@ -64,6 +64,7 @@ mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, http = http_create(); retval = http_get_buf(http, api_call, _decode_folder_get_info, folder); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfapi/apicalls/upload_simple.c b/mfapi/apicalls/upload_simple.c index 969e66a..6467fc4 100644 --- a/mfapi/apicalls/upload_simple.c +++ b/mfapi/apicalls/upload_simple.c @@ -84,6 +84,7 @@ mfconn_api_upload_simple(mfconn * conn, const char *folderkey, file_size, file_hash, _decode_upload_simple, upload_key); http_destroy(http); + mfconn_update_secret_key(conn); free(file_hash); free((void *)api_call); diff --git a/mfapi/apicalls/user_get_info.c b/mfapi/apicalls/user_get_info.c index 5d398f2..adecb49 100644 --- a/mfapi/apicalls/user_get_info.c +++ b/mfapi/apicalls/user_get_info.c @@ -45,6 +45,7 @@ int mfconn_api_user_get_info(mfconn * conn) http = http_create(); retval = http_get_buf(http, api_call, _decode_user_get_info, NULL); http_destroy(http); + mfconn_update_secret_key(conn); free((void *)api_call); diff --git a/mfshell/commands/changes.c b/mfshell/commands/changes.c index ce93159..beae422 100644 --- a/mfshell/commands/changes.c +++ b/mfshell/commands/changes.c @@ -57,7 +57,6 @@ int mfshell_cmd_changes(mfshell * mfshell, int argc, char *const argv[]) changes = NULL; retval = mfconn_api_device_get_changes(mfshell->conn, revision, &changes); - mfconn_update_secret_key(mfshell->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_device_get_changes failed\n"); diff --git a/mfshell/commands/chdir.c b/mfshell/commands/chdir.c index 34dbbd1..cf9393a 100644 --- a/mfshell/commands/chdir.c +++ b/mfshell/commands/chdir.c @@ -83,7 +83,6 @@ int mfshell_cmd_chdir(mfshell * mfshell, int argc, char *const argv[]) } retval = mfconn_api_folder_get_info(mfshell->conn, folder_new, (char *)folderkey); - mfconn_update_secret_key(mfshell->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_folder_get_info failed\n"); diff --git a/mfshell/commands/file.c b/mfshell/commands/file.c index 989279b..de834b4 100644 --- a/mfshell/commands/file.c +++ b/mfshell/commands/file.c @@ -60,7 +60,6 @@ int mfshell_cmd_file(mfshell * mfshell, int argc, char *const argv[]) file = file_alloc(); retval = mfconn_api_file_get_info(mfshell->conn, file, (char *)quickkey); - mfconn_update_secret_key(mfshell->conn); if (retval != 0) { fprintf(stderr, "mfconn_api_file_get_info failed\n"); diff --git a/mfshell/commands/folder.c b/mfshell/commands/folder.c index 764d716..f2c1266 100644 --- a/mfshell/commands/folder.c +++ b/mfshell/commands/folder.c @@ -80,7 +80,6 @@ int mfshell_cmd_folder(mfshell * mfshell, int argc, char *const argv[]) if (retval != 0) { fprintf(stderr, "api call unsuccessful\n"); } - mfconn_update_secret_key(mfshell->conn); folderkey = folder_get_key(folder); name = folder_get_name(folder); diff --git a/mfshell/commands/get.c b/mfshell/commands/get.c index 4e62c54..fb1bbde 100644 --- a/mfshell/commands/get.c +++ b/mfshell/commands/get.c @@ -73,7 +73,6 @@ int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[]) // get file name retval = mfconn_api_file_get_info(mfshell->conn, file, (char *)quickkey); - mfconn_update_secret_key(mfshell->conn); if (retval == -1) { file_free(file); @@ -81,7 +80,6 @@ int mfshell_cmd_get(mfshell * mfshell, int argc, char *const argv[]) } // request a direct download (streaming) link retval = mfconn_api_file_get_links(mfshell->conn, file, (char *)quickkey); - mfconn_update_secret_key(mfshell->conn); if (retval == -1) { file_free(file); diff --git a/mfshell/commands/links.c b/mfshell/commands/links.c index 1bb571c..685800d 100644 --- a/mfshell/commands/links.c +++ b/mfshell/commands/links.c @@ -64,7 +64,6 @@ int mfshell_cmd_links(mfshell * mfshell, int argc, char *const argv[]) if (retval != 0) { fprintf(stderr, "api call unsuccessful\n"); } - mfconn_update_secret_key(mfshell->conn); share_link = file_get_share_link(file); direct_link = file_get_direct_link(file); diff --git a/mfshell/commands/list.c b/mfshell/commands/list.c index c917df2..c86ba56 100644 --- a/mfshell/commands/list.c +++ b/mfshell/commands/list.c @@ -53,7 +53,6 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) mfconn_api_folder_get_content(mfshell->conn, 0, folder_get_key(mfshell->folder_curr), &folder_result, NULL); - mfconn_update_secret_key(mfshell->conn); if (folder_result == NULL) { return -1; @@ -75,7 +74,6 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[]) mfconn_api_folder_get_content(mfshell->conn, 1, folder_get_key(mfshell->folder_curr), NULL, &file_result); - mfconn_update_secret_key(mfshell->conn); for (i = 0; file_result[i] != NULL; i++) { printf("%s %s\n", file_get_name(file_result[i]), diff --git a/mfshell/commands/mkdir.c b/mfshell/commands/mkdir.c index 07266f3..e658022 100644 --- a/mfshell/commands/mkdir.c +++ b/mfshell/commands/mkdir.c @@ -54,7 +54,6 @@ int mfshell_cmd_mkdir(mfshell * mfshell, int argc, char *const argv[]) retval = mfconn_api_folder_create(mfshell->conn, folder_curr, (char *)name); - mfconn_update_secret_key(mfshell->conn); return retval; } diff --git a/mfshell/commands/put.c b/mfshell/commands/put.c index 2c04e3a..6b78e61 100644 --- a/mfshell/commands/put.c +++ b/mfshell/commands/put.c @@ -72,7 +72,6 @@ int mfshell_cmd_put(mfshell * mfshell, int argc, char *const argv[]) retval = mfconn_api_upload_simple(mfshell->conn, folder_get_key(mfshell->folder_curr), fh, file_name, &upload_key); - mfconn_update_secret_key(mfshell->conn); fclose(fh); free(temp); diff --git a/mfshell/commands/rm.c b/mfshell/commands/rm.c index 89199d1..209afc4 100644 --- a/mfshell/commands/rm.c +++ b/mfshell/commands/rm.c @@ -53,7 +53,6 @@ int mfshell_cmd_rm(mfshell * mfshell, int argc, char *const argv[]) } retval = mfconn_api_file_delete(mfshell->conn, quickkey); - mfconn_update_secret_key(mfshell->conn); return retval; } diff --git a/mfshell/commands/rmdir.c b/mfshell/commands/rmdir.c index 697d54c..dd1aa46 100644 --- a/mfshell/commands/rmdir.c +++ b/mfshell/commands/rmdir.c @@ -53,7 +53,6 @@ int mfshell_cmd_rmdir(mfshell * mfshell, int argc, char *const argv[]) } retval = mfconn_api_folder_delete(mfshell->conn, folderkey); - mfconn_update_secret_key(mfshell->conn); return retval; } diff --git a/mfshell/commands/status.c b/mfshell/commands/status.c index 0321009..939aa5c 100644 --- a/mfshell/commands/status.c +++ b/mfshell/commands/status.c @@ -46,7 +46,6 @@ int mfshell_cmd_status(mfshell * mfshell, int argc, char *const argv[]) } // then files retval = mfconn_api_device_get_status(mfshell->conn, &revision); - mfconn_update_secret_key(mfshell->conn); if (retval == 0) { printf("device_revision: %" PRIu64 "\n", revision); } else { diff --git a/mfshell/commands/updates.c b/mfshell/commands/updates.c index 0f50b5d..48feec7 100644 --- a/mfshell/commands/updates.c +++ b/mfshell/commands/updates.c @@ -76,7 +76,6 @@ int mfshell_cmd_updates(mfshell * mfshell, int argc, char *const argv[]) retval = mfconn_api_device_get_updates(mfshell->conn, quickkey, revision, target_revision, &patches); - mfconn_update_secret_key(mfshell->conn); if (retval != 0) { fprintf(stderr, "api call unsuccessful\n"); diff --git a/mfshell/commands/whoami.c b/mfshell/commands/whoami.c index 4046e6d..d4c3204 100644 --- a/mfshell/commands/whoami.c +++ b/mfshell/commands/whoami.c @@ -45,7 +45,6 @@ int mfshell_cmd_whoami(mfshell * mfshell, int argc, char *const argv[]) } retval = mfconn_api_user_get_info(mfshell->conn); - mfconn_update_secret_key(mfshell->conn); return retval; }