Browse Source

Track PM encryption preparation and clean cancelled source files

master
evgeny 1 week ago
parent
commit
51a820ac82
  1. 8
      src/dm/dm_media.c
  2. 2
      src/media_async/attachment_send.c

8
src/dm/dm_media.c

@ -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;
}

2
src/media_async/attachment_send.c

@ -63,6 +63,8 @@ static void attachment_publish(struct attachment_send_req* req, int error) {
chat_event_attachment(req->inst, req->is_dm, req->target, req->id, 2);
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment: preparation failed target=%s error=%d worker=%d", req->target, error, req->error);
if (remove(req->output) && errno != ENOENT) DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "attachment: output cleanup failed path=%s", req->output);
if (req->temporary_source && remove(req->source) && errno != ENOENT)
DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "attachment: abandoned source cleanup failed path=%s", req->source);
u_free(req); return;
}
chat_event_attachment(req->inst, req->is_dm, req->target, req->id, 1);

Loading…
Cancel
Save