mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 21:24:28 -08:00
Allow to create new files (but changing them is not allowed yet)
- since mediafire cannot deal with empty files, we put new files into a temporary location and upload them once they get closed - add create and write functions to fuse - pass a file handle to mfconn_api_upload_simple instead of a path - allow calc_sha256 to also compute the file size - error out when the key returned by upload/simple is empty - make valgrind.supp more lenient
This commit is contained in:
@@ -39,6 +39,7 @@ int mfshell_cmd_put(mfshell * mfshell, int argc, char *const argv[])
|
||||
char *upload_key;
|
||||
int status;
|
||||
int fileerror;
|
||||
FILE *fh;
|
||||
|
||||
if (mfshell == NULL)
|
||||
return -1;
|
||||
@@ -58,25 +59,34 @@ int mfshell_cmd_put(mfshell * mfshell, int argc, char *const argv[])
|
||||
|
||||
file_path = argv[1];
|
||||
|
||||
fh = fopen(file_path, "r");
|
||||
if (fh == NULL) {
|
||||
perror("fopen");
|
||||
fprintf(stderr, "cannot open %s\n", file_path);
|
||||
return -1;
|
||||
}
|
||||
// create copies because basename modifies it
|
||||
temp = strdup(argv[1]);
|
||||
file_name = basename(temp);
|
||||
|
||||
retval = mfconn_api_upload_simple(mfshell->conn,
|
||||
folder_get_key(mfshell->folder_curr),
|
||||
file_path, file_name, &upload_key);
|
||||
fh, file_name, &upload_key);
|
||||
mfconn_update_secret_key(mfshell->conn);
|
||||
|
||||
fclose(fh);
|
||||
free(temp);
|
||||
|
||||
if (retval != 0) {
|
||||
if (retval != 0 || upload_key == NULL) {
|
||||
fprintf(stderr, "mfconn_api_upload_simple failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf(stderr, "upload_key: %s\n", upload_key);
|
||||
|
||||
// poll for completion
|
||||
for (;;) {
|
||||
// no need to update the secret key after this
|
||||
retval = mfconn_api_upload_poll_upload(mfshell->conn, upload_key,
|
||||
&status, &fileerror);
|
||||
if (retval != 0) {
|
||||
|
||||
Reference in New Issue
Block a user