Skip to content

Commit 44d6ecc

Browse files
jpnurmiclaude
andcommitted
fix(transport): only delete db attachment after successful TUS upload
Previously the db copy was deleted unconditionally after the TUS upload attempt, making retries impossible on network or server errors. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9300c82 commit 44d6ecc

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

src/transports/sentry_http_transport.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ tus_upload_item(http_transport_state_t *state, sentry_envelope_item_t *item)
328328
}
329329

330330
if (!req) {
331-
if (file_path) {
332-
sentry__db_remove_large_attachment(state->database_path, file_path);
333-
sentry__path_free(file_path);
334-
}
331+
sentry__path_free(file_path);
335332
return -1;
336333
}
337334

@@ -340,17 +337,17 @@ tus_upload_item(http_transport_state_t *state, sentry_envelope_item_t *item)
340337

341338
bool ok = state->send_func(state->client, req, &resp);
342339
sentry__prepared_http_request_free(req);
343-
if (file_path) {
344-
sentry__db_remove_large_attachment(state->database_path, file_path);
345-
sentry__path_free(file_path);
346-
}
347340

348341
int status_code = ok ? resp.status_code : -1;
349342

350343
if (ok && resp.status_code == 201 && resp.location) {
351344
sentry__envelope_item_set_attachment_ref_location(item, resp.location);
345+
if (file_path) {
346+
sentry__db_remove_large_attachment(state->database_path, file_path);
347+
}
352348
}
353349

350+
sentry__path_free(file_path);
354351
http_response_cleanup(&resp);
355352
return status_code;
356353
}

0 commit comments

Comments
 (0)