Allow importing from a single app .json.

This commit is contained in:
Cory McWilliams 2024-04-30 21:43:14 -04:00
parent 988a807fa4
commit 4edee0f7f6

View File

@ -231,6 +231,12 @@ static void _tf_ssb_import_app_json(tf_ssb_t* ssb, uv_loop_t* loop, JSContext* c
void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path) void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path)
{ {
if (strlen(path) > strlen(".json") && strcasecmp(path + strlen(path) - strlen(".json"), ".json") == 0)
{
_tf_ssb_import_app_json(ssb, tf_ssb_get_loop(ssb), tf_ssb_get_context(ssb), user, path);
}
else
{
uv_fs_t req = { 0 }; uv_fs_t req = { 0 };
int r = uv_fs_scandir(tf_ssb_get_loop(ssb), &req, path, 0, NULL); int r = uv_fs_scandir(tf_ssb_get_loop(ssb), &req, path, 0, NULL);
if (r >= 0) if (r >= 0)
@ -253,6 +259,7 @@ void tf_ssb_import(tf_ssb_t* ssb, const char* user, const char* path)
tf_printf("Failed to scan directory %s: %s.", path, uv_strerror(r)); tf_printf("Failed to scan directory %s: %s.", path, uv_strerror(r));
} }
uv_fs_req_cleanup(&req); uv_fs_req_cleanup(&req);
}
} }
static char* _tf_ssb_import_read_current_file_from_zip(unzFile zip, size_t* size) static char* _tf_ssb_import_read_current_file_from_zip(unzFile zip, size_t* size)