mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
move mfconn_update_secret_key into the apicalls
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user