Skip to content

Commit

Permalink
fetch: Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BastianBlokland committed Feb 1, 2025
1 parent 98b1aa8 commit bd2c486
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions apps/utilities/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ static String fetch_config_uri_scratch(const FetchOrigin* origin, const String a
return dynstring_view(&result);
}

typedef struct {
String configPath;
} FetchContext;

static NetHttpFlags fetch_http_flags(void) {
/**
* Enable Tls transport but do not enable certificate validation.
Expand Down Expand Up @@ -205,13 +201,13 @@ static i32 fetch_run_origin(NetRest* rest, const String targetPath, const FetchO
return retCode;
}

static i32 fetch_run(FetchContext* ctx) {
static i32 fetch_run(const String configPath) {
const TimeSteady timeStart = time_steady_clock();

i32 retCode = 0;
NetRest* rest = null;
FetchConfig cfg;
if (!fetch_config_load(ctx->configPath, &cfg)) {
if (!fetch_config_load(configPath, &cfg)) {
return 1;
}

Expand Down Expand Up @@ -272,14 +268,11 @@ i32 app_cli_run(const CliApp* app, const CliInvocation* invoc) {
log_add_sink(g_logger, log_sink_pretty_default(g_allocHeap, logMask));
log_add_sink(g_logger, log_sink_json_default(g_allocHeap, LogMask_All));

FetchContext ctx = {
.configPath = cli_read_string(invoc, g_optConfigPath, string_empty),
};

fetch_data_init();
net_init();

retCode = fetch_run(&ctx);
const String configPath = cli_read_string(invoc, g_optConfigPath, string_empty);
retCode = fetch_run(configPath);

net_teardown();
return retCode;
Expand Down

0 comments on commit bd2c486

Please sign in to comment.