|
|
|
@ -516,15 +516,15 @@ static void md_auto_download(struct UTUN_INSTANCE* inst, |
|
|
|
uint64_t ts, const uint8_t* author_sig, |
|
|
|
uint64_t ts, const uint8_t* author_sig, |
|
|
|
uint64_t author, int64_t msg_id) { |
|
|
|
uint64_t author, int64_t msg_id) { |
|
|
|
if (!chat_setting_get_int("storage_autoload", 1)) return; |
|
|
|
if (!chat_setting_get_int("storage_autoload", 1)) return; |
|
|
|
int max_mb = chat_setting_get_int("storage_autoload_maxsize_mb", 10); |
|
|
|
uint64_t max_size = g_cc.inst->config->global.chatserver_storage_unit_size; |
|
|
|
|
|
|
|
|
|
|
|
const char* p = data_str; |
|
|
|
const char* p = data_str; |
|
|
|
while (*p && *p != '|') p++; /* skip base filename */ |
|
|
|
while (*p && *p != '|') p++; |
|
|
|
if (!*p) return; p++; |
|
|
|
if (!*p) return; p++; |
|
|
|
long long fsize = strtoll(p, (char**)&p, 10); |
|
|
|
long long fsize = strtoll(p, (char**)&p, 10); |
|
|
|
if (fsize > (long long)max_mb * 1024 * 1024) { |
|
|
|
if (max_size > 0 && fsize > (long long)max_size) { |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: media too large (%lld > %d MB), skip auto-download", |
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DB_SYNC, "%s: media too large (%lld > %llu bytes), skip auto-download", |
|
|
|
CC_ID, fsize, max_mb); |
|
|
|
CC_ID, fsize, (unsigned long long)max_size); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
md_start_download(inst, data_str, data_len, ch_id, base_filename, ts, author_sig, author, msg_id); |
|
|
|
md_start_download(inst, data_str, data_len, ch_id, base_filename, ts, author_sig, author, msg_id); |
|
|
|
|