Allow exporting from a non-default db location. I'm running over NFS on this instance.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3789 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2022-01-23 19:14:43 +00:00
parent 0a580b60b1
commit d0c89991be

View File

@ -238,10 +238,12 @@ xopt_help:
static int _tf_command_export(const char* file, int argc, char* argv[]) static int _tf_command_export(const char* file, int argc, char* argv[])
{ {
typedef struct args_t { typedef struct args_t {
const char* db_path;
bool help; bool help;
} args_t; } args_t;
xoptOption options[] = { xoptOption options[] = {
{ "db-path", 'd', offsetof(args_t, db_path), NULL, XOPT_TYPE_STRING, NULL, "Sqlite database path (default: db.sqlite)." },
{ "help", 'h', offsetof(args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." }, { "help", 'h', offsetof(args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." },
XOPT_NULLOPTION, XOPT_NULLOPTION,
}; };
@ -261,7 +263,12 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
} }
return 2; return 2;
} }
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, NULL, NULL); sqlite3* db = NULL;
if (args.db_path)
{
sqlite3_open(args.db_path, &db);
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db, NULL);
if (extra_count) if (extra_count)
{ {
for (int i = 0; i < extra_count; i++) for (int i = 0; i < extra_count; i++)
@ -284,6 +291,10 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
} }
} }
tf_ssb_destroy(ssb); tf_ssb_destroy(ssb);
if (db)
{
sqlite3_close(db);
}
if (extras) if (extras)
{ {