More blobs.get. Finally replicated again to manyverse.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4102 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-01-02 02:11:21 +00:00
parent 67fbbd4a8d
commit a66a70324d
2 changed files with 12 additions and 6 deletions

View File

@ -1729,6 +1729,7 @@ tf_ssb_t* tf_ssb_create(uv_loop_t* loop, JSContext* context, sqlite3* db)
{
tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t));
memset(ssb, 0, sizeof(*ssb));
ssb->verbose = true;
if (context)
{
ssb->context = context;

View File

@ -36,18 +36,23 @@ static void _tf_ssb_rpc_blobs_get(tf_ssb_connection_t* connection, uint8_t flags
for (int i = 0; i < length; i++)
{
JSValue arg = JS_GetPropertyUint32(context, ids, i);
if (!JS_IsString(arg))
const char* id = NULL;
if (JS_IsString(arg))
{
id = JS_ToCString(context, arg);
}
else
{
JSValue key = JS_GetPropertyStr(context, arg, "key");
JS_FreeValue(context, arg);
arg = key;
id = JS_ToCString(context, key);
JS_FreeValue(context, key);
}
const char* id = JS_ToCString(context, arg);
uint8_t* blob = NULL;
size_t size = 0;
const int k_send_max = 4096;
const int k_send_max = 8192;
if (tf_ssb_db_blob_get(ssb, id, &blob, &size))
{
printf("sending %s (%zd)\n", id, size);
for (size_t offset = 0; offset < size; offset += k_send_max)
{
tf_ssb_connection_rpc_send(
@ -69,7 +74,7 @@ static void _tf_ssb_rpc_blobs_get(tf_ssb_connection_t* connection, uint8_t flags
JS_FreeValue(context, ids);
tf_ssb_connection_rpc_send(
connection,
k_ssb_rpc_flag_json | k_ssb_rpc_flag_end_error,
k_ssb_rpc_flag_json | k_ssb_rpc_flag_end_error | k_ssb_rpc_flag_stream,
-request_number,
(const uint8_t*)(success ? "true" : "false"),
strlen(success ? "true" : "false"),