fix(fc_writer): handle 409 Conflict by fetching existing slot details via GET
This commit is contained in:
parent
5b72ee167d
commit
cc489f7774
1 changed files with 9 additions and 2 deletions
|
|
@ -196,8 +196,15 @@ fc_writer_t *fc_writer_open(const char *fc_url,
|
|||
|
||||
char resp[1024] = {0};
|
||||
int status = http_request("POST", host, port, "/slots", body, resp, sizeof resp);
|
||||
if (status != 201) {
|
||||
fprintf(stderr, "[fc_writer:%s] POST /slots failed (HTTP %d): %s\n",
|
||||
if (status == 409) {
|
||||
/* Already exists, fetch slot details */
|
||||
char path[256];
|
||||
snprintf(path, sizeof path, "/slots/%s", slot_id);
|
||||
status = http_request("GET", host, port, path, NULL, resp, sizeof resp);
|
||||
}
|
||||
|
||||
if (status != 200 && status != 201) {
|
||||
fprintf(stderr, "[fc_writer:%s] POST/GET /slots failed (HTTP %d): %s\n",
|
||||
slot_id, status, resp);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue