Skip to content

Commit ffda5f9

Browse files
committed
Revert sentry_uuid changes
1 parent cd62eb6 commit ffda5f9

File tree

3 files changed

+25
-58
lines changed

3 files changed

+25
-58
lines changed

src/sentry_database.c

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,40 @@ sentry__run_free(sentry_run_t *run)
9999
sentry_free(run);
100100
}
101101

102-
bool
103-
sentry__run_write_envelope(
104-
const sentry_run_t *run, const sentry_envelope_t *envelope)
102+
static sentry_path_t *
103+
write_envelope(const sentry_path_t *path, const sentry_envelope_t *envelope)
105104
{
105+
// 37 for the uuid, 9 for the `.envelope` suffix
106+
char envelope_filename[37 + 9];
106107
sentry_uuid_t event_id = sentry__envelope_get_event_id(envelope);
107-
char *envelope_filename = sentry__uuid_as_filename(&event_id, ".envelope");
108+
sentry_uuid_as_string(&event_id, envelope_filename);
109+
strcpy(&envelope_filename[36], ".envelope");
108110

109-
sentry_path_t *output_path
110-
= sentry__path_join_str(run->run_path, envelope_filename);
111-
sentry_free(envelope_filename);
111+
sentry_path_t *output_path = sentry__path_join_str(path, envelope_filename);
112112
if (!output_path) {
113-
return false;
113+
return NULL;
114114
}
115115

116116
int rv = sentry_envelope_write_to_path(envelope, output_path);
117-
sentry__path_free(output_path);
118-
119117
if (rv) {
120118
SENTRY_WARN("writing envelope to file failed");
119+
sentry__path_free(output_path);
120+
return NULL;
121121
}
122122

123-
// the `write_to_path` returns > 0 on failure, but we would like a real bool
124-
return !rv;
123+
return output_path;
124+
}
125+
126+
bool
127+
sentry__run_write_envelope(
128+
const sentry_run_t *run, const sentry_envelope_t *envelope)
129+
{
130+
sentry_path_t *output_path = write_envelope(run->run_path, envelope);
131+
if (output_path) {
132+
sentry__path_free(output_path);
133+
return true;
134+
}
135+
return false;
125136
}
126137

127138
sentry_path_t *
@@ -134,25 +145,7 @@ sentry__run_write_feedback(
134145
return NULL;
135146
}
136147

137-
sentry_uuid_t event_id = sentry__envelope_get_event_id(envelope);
138-
char *envelope_filename = sentry__uuid_as_filename(&event_id, ".envelope");
139-
140-
sentry_path_t *output_path
141-
= sentry__path_join_str(run->feedback_path, envelope_filename);
142-
sentry_free(envelope_filename);
143-
if (!output_path) {
144-
return NULL;
145-
}
146-
147-
int rv = sentry_envelope_write_to_path(envelope, output_path);
148-
sentry__path_free(output_path);
149-
150-
if (rv) {
151-
SENTRY_WARN("writing envelope to file failed");
152-
}
153-
154-
// the `write_to_path` returns > 0 on failure, but we would like a real bool
155-
return !rv ? output_path : NULL;
148+
return write_envelope(run->feedback_path, envelope);
156149
}
157150

158151
bool

src/sentry_uuid.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "sentry_boot.h"
22

33
#include "sentry_random.h"
4-
#include "sentry_string.h"
54
#include "sentry_uuid.h"
65
#include <stdio.h>
76
#include <string.h>
@@ -130,24 +129,6 @@ sentry__span_uuid_as_string(const sentry_uuid_t *uuid, char str[17])
130129
#undef B
131130
}
132131

133-
char *
134-
sentry__uuid_as_filename(const sentry_uuid_t *uuid, const char *suffix)
135-
{
136-
// 36 for the uuid, suffix, and a null terminator
137-
size_t suffix_len = sentry__guarded_strlen(suffix);
138-
char *buf = sentry_malloc(36 + suffix_len + 1);
139-
if (!buf) {
140-
return NULL;
141-
}
142-
sentry_uuid_as_string(uuid, buf);
143-
buf[36] = '\0';
144-
if (suffix_len > 0) {
145-
memcpy(buf + 36, suffix, suffix_len);
146-
buf[36 + suffix_len] = '\0';
147-
}
148-
return buf;
149-
}
150-
151132
#ifdef SENTRY_PLATFORM_WINDOWS
152133
sentry_uuid_t
153134
sentry__uuid_from_native(const GUID *guid)

src/sentry_uuid.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@ void sentry__internal_uuid_as_string(const sentry_uuid_t *uuid, char str[37]);
1313
* Converts a sentry UUID to a string representation used for span IDs.
1414
*/
1515
void sentry__span_uuid_as_string(const sentry_uuid_t *uuid, char str[17]);
16-
17-
/**
18-
* Converts a sentry UUID to a string representation used for a filename with
19-
* the given suffix.
20-
*/
21-
char *sentry__uuid_as_filename(const sentry_uuid_t *uuid, const char *suffix);
16+
#endif
2217

2318
#ifdef SENTRY_PLATFORM_WINDOWS
2419
/**
2520
* Create a new UUID from the windows-native GUID type.
2621
*/
2722
sentry_uuid_t sentry__uuid_from_native(const GUID *guid);
2823
#endif
29-
30-
#endif

0 commit comments

Comments
 (0)