@@ -71,35 +71,12 @@ sentry__options_unlock(void)
7171 sentry__mutex_unlock (& g_options_lock );
7272}
7373
74- static void
75- load_user_consent (sentry_options_t * opts )
76- {
77- sentry_path_t * consent_path
78- = sentry__path_join_str (opts -> database_path , "user-consent" );
79- char * contents = sentry__path_read_to_buffer (consent_path , NULL );
80- sentry__path_free (consent_path );
81- switch (contents ? contents [0 ] : 0 ) {
82- case '1' :
83- opts -> user_consent = SENTRY_USER_CONSENT_GIVEN ;
84- break ;
85- case '0' :
86- opts -> user_consent = SENTRY_USER_CONSENT_REVOKED ;
87- break ;
88- default :
89- opts -> user_consent = SENTRY_USER_CONSENT_UNKNOWN ;
90- break ;
91- }
92- sentry_free (contents );
93- }
94-
9574bool
9675sentry__should_skip_upload (void )
9776{
9877 bool skip = true;
9978 SENTRY_WITH_OPTIONS (options ) {
100- skip = options -> require_user_consent
101- && sentry__atomic_fetch ((long * )& options -> user_consent )
102- != SENTRY_USER_CONSENT_GIVEN ;
79+ skip = sentry__run_should_skip_upload (options -> run );
10380 }
10481 return skip ;
10582}
@@ -207,8 +184,9 @@ sentry_init(sentry_options_t *options)
207184 SENTRY_WARN ("failed to initialize run directory" );
208185 goto fail ;
209186 }
187+ options -> run -> require_user_consent = options -> require_user_consent ;
210188
211- load_user_consent (options );
189+ sentry__run_load_user_consent (options -> run , options -> database_path );
212190
213191 if (!options -> dsn || !options -> dsn -> is_valid ) {
214192 const char * raw_dsn = sentry_options_get_dsn (options );
@@ -437,7 +415,7 @@ static void
437415set_user_consent (sentry_user_consent_t new_val )
438416{
439417 SENTRY_WITH_OPTIONS (options ) {
440- if (sentry__atomic_store (( long * ) & options -> user_consent , new_val )
418+ if (sentry__atomic_store (& options -> run -> user_consent , new_val )
441419 != new_val ) {
442420 if (options -> backend
443421 && options -> backend -> user_consent_changed_func ) {
@@ -486,7 +464,7 @@ sentry_user_consent_get(void)
486464 sentry_user_consent_t rv = SENTRY_USER_CONSENT_UNKNOWN ;
487465 SENTRY_WITH_OPTIONS (options ) {
488466 rv = (sentry_user_consent_t )(int )sentry__atomic_fetch (
489- ( long * ) & options -> user_consent );
467+ & options -> run -> user_consent );
490468 }
491469 return rv ;
492470}
0 commit comments