From 39d6f19d97604335eda792898eb4abc8ef2dfdb1 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 29 Jul 2026 01:04:27 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20chat=5Fmsg=20media=5Fdir=20path=20?= =?UTF-8?q?=E2=80=94=20strip=20filename=20from=20g=5Fcc.db=5Fpath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit g_cc.db_path is '/data/.../files/chats.db' (file path), but media blocks are written to '/data/.../files/media//'. chat_msg was concatenating 'chats.db/media/...' — now strips the database filename, using only the directory portion for the media path. --- src/chat/chat_msg.c | 11 ++++++++++- tools/chatgui-android/libutun_lite/voice_recorder.c | 7 +++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/chat/chat_msg.c b/src/chat/chat_msg.c index b760c3a2..f44fe5a1 100644 --- a/src/chat/chat_msg.c +++ b/src/chat/chat_msg.c @@ -101,7 +101,16 @@ static void chat_core_submit_media_message(struct chat_msg_submit* req) { if (!si) { DEBUG_ERROR(DEBUG_CATEGORY_DB_SYNC, "%s: no db_sync instance for ch=%s", CC_ID, req->channel_id); return; } char media_dir[1024]; - snprintf(media_dir, sizeof(media_dir), "%s/media/%s", g_cc.db_path, req->channel_id); + { + /* g_cc.db_path is a file path (e.g. /data/.../chats.db). + Extract directory portion for media path. */ + const char* last_slash = strrchr(g_cc.db_path, '/'); + if (last_slash) + snprintf(media_dir, sizeof(media_dir), "%.*s/media/%s", + (int)(last_slash - g_cc.db_path), g_cc.db_path, req->channel_id); + else + snprintf(media_dir, sizeof(media_dir), "%s/media/%s", g_cc.db_path, req->channel_id); + } uint32_t num_blocks = req->media_num_blocks; uint64_t block_size = 0; diff --git a/tools/chatgui-android/libutun_lite/voice_recorder.c b/tools/chatgui-android/libutun_lite/voice_recorder.c index e9e0805a..355c6104 100644 --- a/tools/chatgui-android/libutun_lite/voice_recorder.c +++ b/tools/chatgui-android/libutun_lite/voice_recorder.c @@ -85,6 +85,7 @@ int voice_recorder_init(const char* db_path) { DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "voice_recorder_init: db=%s preset=%d compressor=%d", g_rec->db_path, g_rec->preset, g_rec->compressor_enabled); + debug_set_category_level(DEBUG_CATEGORY_GENERAL, DEBUG_LEVEL_INFO); pthread_mutex_unlock(&g_init_mtx); return 0; } @@ -339,8 +340,8 @@ int voice_recorder_stop(int* out_duration_ms) { opus_codec_encoder_destroy(enc); float duration_sec = (float)frame_count * FRAME_MS / 1000.0f; - DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "voice_recorder_stop: %d frames (%.1fs) dur=%lldms compressor=%d", - frame_count, duration_sec, (long long)elapsed_ms, g_rec->compressor_enabled); + DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "voice_recorder_stop: wrote %d frames (%.1fs) dur=%lldms compressor=%d path=%s", + frame_count, duration_sec, (long long)elapsed_ms, g_rec->compressor_enabled, temp_path); if (frame_count <= 0) { unlink(temp_path); @@ -356,6 +357,8 @@ int voice_recorder_stop(int* out_duration_ms) { uint32_t block_size = media_calc_block_size(file_size); int num_blocks = (int)((file_size + block_size - 1) / block_size); + DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "voice_recorder_stop: file_size=%llu block_size=%u num_blocks=%d", + (unsigned long long)file_size, block_size, num_blocks); /* split file into blocks */ FILE* src = fopen(temp_path, "rb");