diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-07-04 18:58:06 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-07-04 18:58:06 +0900 |
| commit | 61fa05ec0c4510f1cd437b5d672cd6fd7b996353 (patch) | |
| tree | c5afdc1d63c2613809a8d514276c43f0990a7cb1 /src/app | |
| parent | 751999a82b8854ef5231e0ded5fe022b1ea5d8ff (diff) | |
Bound import memory with staged streaming
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/main.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/app/main.c b/src/app/main.c index 415e999..157c8b2 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -61,26 +61,16 @@ run_server(tiny_store_t *store) return result; } -static int -run_cli_command(tiny_store_t *store, const tiny_sys_arguments_t *arguments) +static void +read_cli_options(tiny_cli_options_t *options, const tiny_sys_arguments_t *arguments) { - tiny_cli_options_t options = { 0 }; - options.data_dir = arguments->values[2]; - options.import_path = find_argument(arguments, "--import"); - options.export_path = find_argument(arguments, "--export"); - options.session_id = find_argument(arguments, "--session"); - options.policy_name = find_argument(arguments, "--policy"); - options.include_deleted = flag_present(arguments, "--include-deleted"); - - if (options.import_path) - { - return tiny_cli_import(store, &options); - } - if (options.export_path) - { - return tiny_cli_export(store, &options); - } - return 2; + memset(options, 0, sizeof(*options)); + options->data_dir = arguments->values[2]; + options->import_path = find_argument(arguments, "--import"); + options->export_path = find_argument(arguments, "--export"); + options->session_id = find_argument(arguments, "--session"); + options->policy_name = find_argument(arguments, "--policy"); + options->include_deleted = flag_present(arguments, "--include-deleted"); } static int @@ -91,6 +81,7 @@ run(const tiny_sys_arguments_t *arguments) tiny_store_status_t status; int result; int server_mode = 0; + tiny_cli_options_t options; if (arguments->count == 2 && strcmp(arguments->values[1], "--help") == 0) { usage(stdout); @@ -116,15 +107,24 @@ run(const tiny_sys_arguments_t *arguments) fprintf(stderr, "unable to resolve --data-dir\n"); return 2; } + read_cli_options(&options, arguments); + options.data_dir = absolute; + if (options.import_path) + { + result = tiny_cli_import(&options); + free(absolute); + return result; + } status = tiny_store_open(&store, absolute); - free(absolute); if (status != TINY_STORE_OK) { fprintf(stderr, "unable to open conversation store: %s\n", tiny_store_status_name(status)); + free(absolute); return status == TINY_STORE_BUSY ? 3 : 1; } - result = server_mode ? run_server(store) : run_cli_command(store, arguments); + result = server_mode ? run_server(store) : tiny_cli_export(store, &options); tiny_store_close(store); + free(absolute); return result; } |
