forked from cory/tildefriends
		
	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:
		| @@ -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)); | 	tf_ssb_t* ssb = tf_malloc(sizeof(tf_ssb_t)); | ||||||
| 	memset(ssb, 0, sizeof(*ssb)); | 	memset(ssb, 0, sizeof(*ssb)); | ||||||
|  | 	ssb->verbose = true; | ||||||
| 	if (context) | 	if (context) | ||||||
| 	{ | 	{ | ||||||
| 		ssb->context = context; | 		ssb->context = context; | ||||||
|   | |||||||
| @@ -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++) | 	for (int i = 0; i < length; i++) | ||||||
| 	{ | 	{ | ||||||
| 		JSValue arg = JS_GetPropertyUint32(context, ids, 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"); | 			JSValue key = JS_GetPropertyStr(context, arg, "key"); | ||||||
| 			JS_FreeValue(context, arg); | 			id = JS_ToCString(context, key); | ||||||
| 			arg = key; | 			JS_FreeValue(context, key); | ||||||
| 		} | 		} | ||||||
| 		const char* id = JS_ToCString(context, arg); |  | ||||||
| 		uint8_t* blob = NULL; | 		uint8_t* blob = NULL; | ||||||
| 		size_t size = 0; | 		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)) | 		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) | 			for (size_t offset = 0; offset < size; offset += k_send_max) | ||||||
| 			{ | 			{ | ||||||
| 				tf_ssb_connection_rpc_send( | 				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); | 	JS_FreeValue(context, ids); | ||||||
| 	tf_ssb_connection_rpc_send( | 	tf_ssb_connection_rpc_send( | ||||||
| 		connection, | 		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, | 		-request_number, | ||||||
| 		(const uint8_t*)(success ? "true" : "false"), | 		(const uint8_t*)(success ? "true" : "false"), | ||||||
| 		strlen(success ? "true" : "false"), | 		strlen(success ? "true" : "false"), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user