fix: chat_msg media_dir path — strip filename from g_cc.db_path

g_cc.db_path is '/data/.../files/chats.db' (file path), but media blocks
are written to '/data/.../files/media/<channel>/'. chat_msg was concatenating
'chats.db/media/...' — now strips the database filename, using only the
directory portion for the media path.
This commit is contained in:
evgeny committed 2026-07-29 01:04:27 +03:00
1 parent b11e705f7a
commit 39d6f19d97
2 files changed
+15 -3

No files matched your search

+10 -1
View File
@@ -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;