Related to rhbz#947870
Signed-off-by: Jakub Filak <jfilak(a)redhat.com>
---
src/daemon/abrtd.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
index 7bc93ef..2541ea8 100644
--- a/src/daemon/abrtd.c
+++ b/src/daemon/abrtd.c
@@ -434,6 +434,34 @@ static gboolean handle_event_output_cb(GIOChannel *gio, GIOCondition
condition,
char new_count_str[sizeof(long)*3 + 2];
sprintf(new_count_str, "%lu", count);
dd_save_text(dd, FILENAME_COUNT, new_count_str);
+
+ /* Update the last occurrence file */
+ struct dump_dir *new_dd = dd_opendir(state->dirname,
+ DD_OPEN_READONLY | DD_FAIL_QUIETLY_ENOENT | DD_FAIL_QUIETLY_EACCES);
+ char *last_ocr = NULL;
+ if (new_dd)
+ {
+ /* TIME must exists in a valid dump directory but we don't want to die
+ * due to broken duplicated dump directory */
+ last_ocr = dd_load_text_ext(new_dd, FILENAME_TIME,
+ DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE | DD_FAIL_QUIETLY_ENOENT);
+ dd_close(new_dd);
+ }
+ else
+ { /* dd_opendir() already produced a message with good information about
failure */
+ error_msg("Can't read the last occurrence file from the new dump
directory.");
+ }
+
+ if (!last_ocr)
+ { /* the new dump directory may lie in the dump location for some time */
+ log("Using current time for the last occurrence file which may be
incorrect.");
+ time_t t = time(NULL);
+ last_ocr = xasprintf("%lu", (long)t);
+ }
+
+ dd_save_text(dd, FILENAME_LAST_OCCURRENCE, last_ocr);
+
+ free(last_ocr);
}
/* Reset mode/uig/gid to correct values for all files created by event run */
--
1.8.1.4