forked from cory/tildefriends
Finish import.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4167 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
b2fbe9dfac
commit
ffda896308
@ -154,6 +154,24 @@ static void _tf_ssb_import_recursive_add_files(tf_ssb_t* ssb, uv_loop_t* loop, J
|
|||||||
uv_fs_req_cleanup(&req);
|
uv_fs_req_cleanup(&req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool _tf_ssb_register_app(tf_ssb_t* ssb, const char* user, const char* app, const char* id)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
sqlite3_stmt* statement;
|
||||||
|
if (sqlite3_prepare(tf_ssb_get_db(ssb), "INSERT OR REPLACE INTO properties (id, key, value) VALUES ($1, 'path:' || $2, $3)", -1, &statement, NULL) == SQLITE_OK)
|
||||||
|
{
|
||||||
|
if (sqlite3_bind_text(statement, 1, user, -1, NULL) == SQLITE_OK &&
|
||||||
|
sqlite3_bind_text(statement, 2, app, -1, NULL) == SQLITE_OK &&
|
||||||
|
sqlite3_bind_text(statement, 3, id, -1, NULL) == SQLITE_OK &&
|
||||||
|
sqlite3_step(statement) == SQLITE_DONE)
|
||||||
|
{
|
||||||
|
result = sqlite3_changes(tf_ssb_get_db(ssb)) != 0;
|
||||||
|
}
|
||||||
|
sqlite3_finalize(statement);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static void _tf_ssb_import_app_json(tf_ssb_t* ssb, uv_loop_t* loop, JSContext* context, const char* user, const char* path)
|
static void _tf_ssb_import_app_json(tf_ssb_t* ssb, uv_loop_t* loop, JSContext* context, const char* user, const char* path)
|
||||||
{
|
{
|
||||||
uv_fs_t req = { 0 };
|
uv_fs_t req = { 0 };
|
||||||
@ -182,7 +200,12 @@ static void _tf_ssb_import_app_json(tf_ssb_t* ssb, uv_loop_t* loop, JSContext* c
|
|||||||
const char* app = dir;
|
const char* app = dir;
|
||||||
char* slash = strrchr(dir, '/');
|
char* slash = strrchr(dir, '/');
|
||||||
app = slash ? slash + 1 : app;
|
app = slash ? slash + 1 : app;
|
||||||
_tf_ssb_import_add_app(ssb, user, app);
|
|
||||||
|
if (_tf_ssb_register_app(ssb, user, app, id))
|
||||||
|
{
|
||||||
|
printf("Registered %s path:%s as %s.\n", user, app, id);
|
||||||
|
_tf_ssb_import_add_app(ssb, user, app);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JS_FreeCString(context, blob);
|
JS_FreeCString(context, blob);
|
||||||
JS_FreeValue(context, json);
|
JS_FreeValue(context, json);
|
||||||
|
Loading…
Reference in New Issue
Block a user