Skip to content

Commit

Permalink
[mms-lib] Don't delete m-notification.ind if we are keeping temp files
Browse files Browse the repository at this point in the history
Additionally, move it from the directory with the fake id to the directory
associated with the message once we know which id commhistoryd has assigned
to this message.

These changes are only useful for debugging, if mms-engine is started
with -t option. They have no effect on the normal operation.
  • Loading branch information
monich committed Nov 12, 2014
1 parent 50c9bf4 commit 376c31a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions mms-lib/src/mms_task_notification.c
Expand Up @@ -90,16 +90,32 @@ mms_task_notification_done(
if (id[0]) {
MMS_DEBUG(" Database id: %s", id);
if (task->id) {
/* Remove temporary directory and files */
char* dir = mms_task_dir(task);
char* file = mms_task_file(task, MMS_NOTIFICATION_IND_FILE);
remove(file);
remove(dir);
g_free(file);
g_free(dir);
char* olddir = mms_task_dir(task);
char* file = g_strconcat(olddir, "/"
MMS_NOTIFICATION_IND_FILE, NULL);
/* Replace fake id with the real one */
g_free(task->id);
task->id = g_strdup(id);
if (task_config(task)->keep_temp_files) {
/* Move file to the new place */
char* newdir = mms_task_dir(task);
if (rename(olddir, newdir) == 0) {
MMS_VERBOSE("Moved %s to %s", file, newdir);
} else {
MMS_ERR("Failed to rename %s to %s: %s", olddir,
newdir, strerror(errno));
}
g_free(newdir);
} else {
/* Remove temporary directory and file */
remove(file);
remove(olddir);
}
g_free(file);
g_free(olddir);
} else {
task->id = g_strdup(id);
}
task->id = g_strdup(id);

/* Schedule the download task */
if (!mms_task_queue_and_unref(task->delegate,
Expand Down

0 comments on commit 376c31a

Please sign in to comment.