-
Notifications
You must be signed in to change notification settings - Fork 42
Provide file metadata in storj_finished_upload_cb, not only file id #410
Conversation
The bridge API returns complete file metadata for uploaded files, but the storj_finished_upload_cb callback passed only the file id to libstorj clients. Thus, clients needed to execute an additional call to the bridge for retrieving metadata of interest like Created Time or HMAC. This causes unnecessary complexity and latency for clients and unnecessary load to the bridge.
@braydonf Note that this is a backward incompatible change for libstorj clients as the signature of the I would also appreciate a close review of the memory management as it is very easy to make it wrong. |
STORJ_API void storj_free_uploaded_file_info(storj_file_meta_t *file) | ||
{ | ||
if (file) { | ||
free((char *)file->id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we need to check if these are allocated before freeing too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
free(NULL) is noop, isn't it? https://stackoverflow.com/a/1938758/2356099
test/tests.c
Outdated
{ | ||
assert(handle == NULL); | ||
if (error_code == 0) { | ||
if (strcmp(file_id, "85fb0ed00de1196dc22e0f6d") == 0 ) { | ||
if (strcmp(file->id, "85fb0ed00de1196dc22e0f6d") == 0 ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if file is NULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
We should remember to bump the |
The bridge API returns complete file metadata for uploaded files, but the
storj_finished_upload_cb
callback passed only the file id to libstorj clients. Thus, clients needed to execute an additional call to the bridge for retrieving metadata of interest like Created Time or HMAC. This causes unnecessary complexity and latency for clients and unnecessary load to the bridge.