From 9d55bb6b35bab5412fcb733c82de652dc7407035 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 16 Jan 2025 09:07:12 -0400 Subject: [PATCH] MT#61822 report errors from caching files Change-Id: Ideb8ff399a710e912aef5dbc7629e2eda8691b19 --- daemon/media_player.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/daemon/media_player.c b/daemon/media_player.c index de0fa1246..e31c5f3ad 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -1259,12 +1259,13 @@ static struct media_player_media_file *media_player_media_file_read_str(const st static const char *media_player_get_db_id(str *out, unsigned long long id, str (*dup_fn)(const char *, size_t), - void (*cache_fn)(const char *s, size_t len, unsigned long long id)); + bool (*cache_fn)(const char *s, size_t len, unsigned long long id)); -static void media_player_add_cache_file_dummy(const char *s, size_t len, unsigned long long id) { +static bool media_player_add_cache_file_dummy(const char *s, size_t len, unsigned long long id) { + return true; } -static void (*media_player_add_cache_file)(const char *s, size_t len, unsigned long long id) = +static bool (*media_player_add_cache_file)(const char *s, size_t len, unsigned long long id) = media_player_add_cache_file_dummy; @@ -1798,9 +1799,9 @@ static char *media_player_make_cache_entry_name(unsigned long long id) { return g_strdup_printf("%s/%llu.blob", rtpe_config.db_media_cache, id); } -static void media_player_add_cache_file_create(const char *s, size_t len, unsigned long long id) { +static bool media_player_add_cache_file_create(const char *s, size_t len, unsigned long long id) { if (!rtpe_config.db_media_cache) - return; + return false; g_autoptr(char) fn = media_player_make_cache_entry_name(id); GError *err = NULL; @@ -1808,7 +1809,9 @@ static void media_player_add_cache_file_create(const char *s, size_t len, unsign if (!ok) { ilog(LOG_WARN, "Failed to write to cache file '%s': %s", fn, err->message); g_error_free(err); + return false; } + return true; } static str dummy_dup(const char *s, size_t l) { @@ -1817,7 +1820,7 @@ static str dummy_dup(const char *s, size_t l) { static const char *media_player_get_db_id(str *out, unsigned long long id, str (*dup_fn)(const char *, size_t), - void (*cache_fn)(const char *s, size_t len, unsigned long long id)) + bool (*cache_fn)(const char *s, size_t len, unsigned long long id)) { const char *err; g_autoptr(char) query = NULL; @@ -1863,7 +1866,9 @@ success:; goto err; } - cache_fn(row[0], lengths[0], id); + err = "failed to insert data into cache"; + if (!cache_fn(row[0], lengths[0], id)) + goto err; *out = dup_fn(row[0], lengths[0]); return NULL;