mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
move loop polling for upload completion into separate function
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "../utils/http.h"
|
||||
|
||||
const char *mfconn_file_link_types[] = {
|
||||
const char *mfconn_file_link_types[] = {
|
||||
"normal_download",
|
||||
"direct_download",
|
||||
"view",
|
||||
|
||||
@@ -54,7 +54,7 @@ enum mfconn_file_link_type {
|
||||
MFCONN_FILE_LINK_TYPE_ONE_TIME_DOWNLOAD
|
||||
};
|
||||
|
||||
extern const char *mfconn_file_link_types[]; // declared in apicalls.c
|
||||
extern const char *mfconn_file_link_types[]; // declared in apicalls.c
|
||||
|
||||
struct mfconn_device_change {
|
||||
enum mfconn_device_change_type change;
|
||||
@@ -72,7 +72,8 @@ int mfconn_api_file_get_info(mfconn * conn, mffile * file,
|
||||
|
||||
int mfconn_api_file_get_links(mfconn * conn, mffile * file,
|
||||
const char *quickkey,
|
||||
enum mfconn_file_link_type link_mask);
|
||||
enum mfconn_file_link_type
|
||||
link_mask);
|
||||
|
||||
int mfconn_api_file_move(mfconn * conn, const char *quickkey,
|
||||
const char *folderkey);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../utils/strings.h"
|
||||
#include "apicalls.h"
|
||||
@@ -402,3 +403,29 @@ int mfconn_get_max_num_retries(mfconn * conn)
|
||||
{
|
||||
return conn->max_num_retries;
|
||||
}
|
||||
|
||||
int mfconn_upload_poll_for_completion(mfconn * conn, const char *upload_key)
|
||||
{
|
||||
int status;
|
||||
int fileerror;
|
||||
int retval;
|
||||
|
||||
for (;;) {
|
||||
// no need to update the secret key after this
|
||||
retval = mfconn_api_upload_poll_upload(conn, upload_key, &status,
|
||||
&fileerror);
|
||||
if (retval != 0) {
|
||||
fprintf(stderr, "mfconn_api_upload_poll_upload failed\n");
|
||||
return -1;
|
||||
}
|
||||
fprintf(stderr, "status: %d, filerror: %d\n", status, fileerror);
|
||||
|
||||
// values 98 and 99 are terminal states for a completed upload
|
||||
if (status == 99 || status == 98) {
|
||||
fprintf(stderr, "done\n");
|
||||
break;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,4 +59,7 @@ uint32_t mfconn_get_secret_key(mfconn * conn);
|
||||
|
||||
int mfconn_get_max_num_retries(mfconn * conn);
|
||||
|
||||
int mfconn_upload_poll_for_completion(mfconn * conn,
|
||||
const char *upload_key);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user