From c169ba9d9e540f02a0b853f5966fb09c9beb82a3 Mon Sep 17 00:00:00 2001 From: zshuang0316 Date: Thu, 26 Feb 2026 16:12:49 +0800 Subject: [PATCH] in_blob: Add conditional check for database file before insert Signed-off-by: zshuang0316 --- plugins/in_blob/blob_file.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/in_blob/blob_file.c b/plugins/in_blob/blob_file.c index aa853fbbc36..07ac779fecc 100644 --- a/plugins/in_blob/blob_file.c +++ b/plugins/in_blob/blob_file.c @@ -78,11 +78,13 @@ int blob_file_append(struct blob_ctx *ctx, char *path, struct stat *st) #ifdef FLB_HAVE_SQLDB /* insert the entry into the database */ - bfile->db_id = blob_db_file_insert(ctx, path, st->st_size); - if (bfile->db_id < 0) { - cfl_sds_destroy(bfile->path); - flb_free(bfile); - return -1; + if (ctx->database_file) { + bfile->db_id = blob_db_file_insert(ctx, path, st->st_size); + if (bfile->db_id < 0) { + cfl_sds_destroy(bfile->path); + flb_free(bfile); + return -1; + } } #endif