|
|
|
|
@ -433,6 +433,7 @@ static void dm_file_done(void* arg, int error) {
|
|
|
|
|
if (dm_send(inst, job->conv, "file", data, (uint32_t)(DM_MEDIA_DESC_SIZE + n))) goto fail; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DM, "dm_media: prepared conv=%s bytes=%llu name=%s", job->conv, |
|
|
|
|
(unsigned long long)job->size, job->info.name); |
|
|
|
|
chat_event_attachment(inst, 1, job->conv, job->id, 1); |
|
|
|
|
dm_job_free(job); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
@ -488,7 +489,11 @@ static void dm_file_done(void* arg, int error) {
|
|
|
|
|
fail: |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_DM, "dm_media: file task failed/cancelled work=%d error=%d worker=%d closing=%d", |
|
|
|
|
job->work, error, job->error, media->closing); |
|
|
|
|
if (job->work == DM_FILE_PREPARE) { dm_file_remove(job->plain); dm_file_remove(job->cipher); } |
|
|
|
|
if (job->work == DM_FILE_PREPARE) { |
|
|
|
|
chat_event_attachment(inst, 1, job->conv, job->id, 2); |
|
|
|
|
dm_file_remove(job->plain); dm_file_remove(job->cipher); |
|
|
|
|
if (job->remove_source) dm_file_remove(job->input); |
|
|
|
|
} |
|
|
|
|
else if (!custody) { |
|
|
|
|
sqlite3_stmt* st = dm_media_prepare(inst, "UPDATE dm_files SET downloading=0 WHERE id=? AND dir=0"); |
|
|
|
|
if (st) { sqlite3_bind_blob(st, 1, job->id, 16, SQLITE_STATIC); dm_media_step(inst, st); } |
|
|
|
|
@ -603,6 +608,7 @@ int dm_send_file(struct UTUN_INSTANCE* inst, const char* conv, const char* path,
|
|
|
|
|
} |
|
|
|
|
job->next = media->jobs; media->jobs = job; |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_DM, "dm_media: preparing conv=%s kind=%d name=%s", conv, info->kind, info->name); |
|
|
|
|
chat_event_attachment(inst, 1, conv, job->id, 0); |
|
|
|
|
media_async_submit(inst->media_async, inst->ua, dm_file_work, job, dm_file_done, job); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|