Skip to content

Commit 3aba96d

Browse files
committed
refactor: improve S3 configuration defaults, mark unused functions, and suppress compiler warnings
1 parent e30af23 commit 3aba96d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/class.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static int get_env_int_default(const char *env_var, int default_val) {
355355
// Configurable via ARKILIAN_MAX_ATTEMPTS env var. Default 20 with
356356
// exponential backoff gives ~1 hour of retrying before dead-lettering.
357357
// Tests set a lower value (e.g. 3) to dead-letter quickly.
358+
__attribute__((unused))
358359
static int max_attempts(void) {
359360
int v = get_env_int_default("ARKILIAN_MAX_ATTEMPTS", 100);
360361
if (v < 1) v = 1;
@@ -1410,6 +1411,7 @@ static long curl_timeout_sec(size_t bytes, long base) {
14101411
return t;
14111412
}
14121413

1414+
__attribute__((unused))
14131415
static ship_result_t ship_to_backup(arkilian *db, CURL *curl,
14141416
sqlite3_int64 id, const char *payload) {
14151417
if (!payload || strlen(payload) == 0) return SHIP_OK;
@@ -2191,7 +2193,9 @@ int db_init(arkilian **db_ptr, const char *filename) {
21912193
db->chunk_interval = get_env_int_default("ARKILIAN_CHUNK_INTERVAL_SEC",
21922194
CHUNK_FLUSH_INTERVAL_SEC);
21932195
if (db->chunk_interval < 1) db->chunk_interval = 1;
2194-
db->chunk_enabled = get_env_bool_default("ARKILIAN_WAL_DIRECT_S3", 1);
2196+
db->chunk_enabled = get_env_bool_default("ARKILIAN_WAL_DIRECT_S3",
2197+
(db->s3_endpoint && db->s3_endpoint[0] &&
2198+
db->s3_access_key && db->s3_access_key[0]) ? 1 : 0);
21952199
// ARKILIAN_ALLOW_INSECURE=1 opts into cleartext http:// endpoints that
21962200
// are NOT loopback/RFC1918 (e.g. an internal-but-public corporate
21972201
// aggregator). Default 0: anything non-https and non-local is refused.
@@ -3948,6 +3952,8 @@ static void manifest_write(arkilian *db, const char *snapshot_s3_key,
39483952
if (!db->s3_tenant_prefix || !db->s3_tenant_prefix[0]) return;
39493953
if (strstr(db->s3_tenant_prefix, "..") || db->s3_tenant_prefix[0] == '/')
39503954
return;
3955+
if (strstr(db->s3_tenant_prefix, "..") || db->s3_tenant_prefix[0] == '/')
3956+
return;
39513957

39523958
char json_buf[4096];
39533959
int n = snprintf(json_buf, sizeof(json_buf),

src/hydration.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ int arkilian_hydrate_s3(const char *db_path,
10231023
const char *s3_prefix,
10241024
hydration_progress_cb progress,
10251025
void *user_data) {
1026+
(void)server_url;
10261027
if (!db_path) return HYDRATION_ERR_PROTO;
10271028

10281029
pthread_mutex_lock(&g_hydrate_mutex);

0 commit comments

Comments
 (0)