Skip to content

Commit

Permalink
Merge pull request #58 from monich/temp_ind
Browse files Browse the repository at this point in the history
Don't delete m-notification.ind if we are keeping temp files
  • Loading branch information
monich committed Nov 13, 2014
2 parents 50c9bf4 + 376c31a commit 23eb9d3
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 23eb9d3

Please sign in to comment.