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:
@@ -69,8 +69,6 @@ int filecache_upload_patch(const char *quickkey, uint64_t local_revision,
|
||||
char *patch_file;
|
||||
int retval;
|
||||
char *upload_key;
|
||||
int status;
|
||||
int fileerror;
|
||||
|
||||
cachefile = strdup_printf("%s/%s_%d", filecache_path, quickkey,
|
||||
local_revision);
|
||||
@@ -151,26 +149,14 @@ int filecache_upload_patch(const char *quickkey, uint64_t local_revision,
|
||||
return -1;
|
||||
}
|
||||
// poll for completion
|
||||
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);
|
||||
}
|
||||
|
||||
retval = mfconn_upload_poll_for_completion(conn, upload_key);
|
||||
free(upload_key);
|
||||
|
||||
if (retval != 0) {
|
||||
fprintf(stderr, "mfconn_upload_poll_for_completion failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -450,8 +450,6 @@ int mediafirefs_release(const char *path, struct fuse_file_info *file_info)
|
||||
int retval;
|
||||
struct mediafirefs_context_private *ctx;
|
||||
struct mediafirefs_openfile *openfile;
|
||||
int status;
|
||||
int fileerror;
|
||||
|
||||
ctx = fuse_get_context()->private_data;
|
||||
|
||||
@@ -511,26 +509,14 @@ int mediafirefs_release(const char *path, struct fuse_file_info *file_info)
|
||||
return -EACCES;
|
||||
}
|
||||
// poll for completion
|
||||
for (;;) {
|
||||
// no need to update the secret key after this
|
||||
retval = mfconn_api_upload_poll_upload(ctx->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);
|
||||
}
|
||||
|
||||
retval = mfconn_upload_poll_for_completion(ctx->conn, upload_key);
|
||||
free(upload_key);
|
||||
|
||||
if (retval != 0) {
|
||||
fprintf(stderr, "mfconn_upload_poll_for_completion failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
folder_tree_update(ctx->tree, ctx->conn, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user