diff -Nru whoopsie-0.2.7/debian/changelog whoopsie-0.2.7.1/debian/changelog --- whoopsie-0.2.7/debian/changelog 2012-10-25 10:46:18.000000000 +0000 +++ whoopsie-0.2.7.1/debian/changelog 2012-12-14 00:27:38.000000000 +0000 @@ -1,3 +1,10 @@ +whoopsie (0.2.7.1) quantal-proposed; urgency=low + + * Do not modify the .uploaded file corresponding to a .crash file when + starting up (LP: #1084311) + + -- Brian Murray Thu, 13 Dec 2012 16:26:40 -0800 + whoopsie (0.2.7) quantal-proposed; urgency=low * Also include the InstallationMedia field so that we can tie the diff -Nru whoopsie-0.2.7/src/tests/test_parse_report.c whoopsie-0.2.7.1/src/tests/test_parse_report.c --- whoopsie-0.2.7/src/tests/test_parse_report.c 2012-08-29 08:57:59.000000000 +0000 +++ whoopsie-0.2.7.1/src/tests/test_parse_report.c 2012-12-14 00:28:27.000000000 +0000 @@ -23,9 +23,11 @@ #include #include #include +#include #include #include #include +#include #include "../src/whoopsie.h" @@ -330,6 +332,50 @@ } } +static void +test_process_existing (void) +{ + int fd; + int fd1; + int fd2; + char report_dir[12] = "/tmp/XXXXXX"; + char* crash_file = NULL; + char* upload_file = NULL; + char* uploaded_file = NULL; + + struct stat before_uploaded_stat; + struct stat after_uploaded_stat; + + mkdtemp (report_dir); + asprintf (&crash_file, "%s/fake.crash", report_dir); + asprintf (&upload_file, "%s/fake.upload", report_dir); + asprintf (&uploaded_file, "%s/fake.uploaded", report_dir); + + fd = creat (crash_file, 0600); + fd1 = creat (upload_file, 0600); + sleep (1); + fd2 = creat (uploaded_file, 0600); + close (fd); + close (fd1); + close (fd2); + + stat (uploaded_file, &before_uploaded_stat); + sleep (1); + process_existing_files (report_dir); + stat (uploaded_file, &after_uploaded_stat); + /* Process existing should not modify the .uploaded file LP: #1084311 */ + if (before_uploaded_stat.st_mtime != after_uploaded_stat.st_mtime) { + g_test_fail (); + } + unlink (crash_file); + free (crash_file); + unlink (upload_file); + free (upload_file); + unlink (uploaded_file); + free (uploaded_file); + rmdir (report_dir); +} + int main (int argc, char** argv) { @@ -349,6 +395,7 @@ test_valid_report_empty_value); g_test_add_func ("/whoopsie/no-newline", test_no_newline); g_test_add_func ("/whoopsie/unicode", test_unicode); + g_test_add_func ("/whoopsie/process-existing", test_process_existing); const char* key_no_value_data[] = { TEST_DIR "/data/crash/invalid_key_no_value", diff -Nru whoopsie-0.2.7/src/tests/test_utils.c whoopsie-0.2.7.1/src/tests/test_utils.c --- whoopsie-0.2.7/src/tests/test_utils.c 2012-03-23 12:34:54.000000000 +0000 +++ whoopsie-0.2.7.1/src/tests/test_utils.c 2012-12-14 00:26:26.000000000 +0000 @@ -169,6 +169,9 @@ g_warning ("Unable to remove %s.", upload_file); if (unlink (uploaded_file) < 0) g_warning ("Unable to remove %s.", uploaded_file); + free (crash_file); + free (upload_file); + free (uploaded_file); } static void diff -Nru whoopsie-0.2.7/src/whoopsie.c whoopsie-0.2.7.1/src/whoopsie.c --- whoopsie-0.2.7/src/whoopsie.c 2012-10-25 10:43:34.000000000 +0000 +++ whoopsie-0.2.7.1/src/whoopsie.c 2012-12-14 00:32:40.000000000 +0000 @@ -74,6 +74,9 @@ /* The file descriptor for our instance lock */ static int lock_fd = 0; +/* The report directory */ +static const char* report_dir = "/var/crash"; + /* Options */ static gboolean foreground = FALSE; @@ -643,7 +646,7 @@ } void -process_existing_files (void) +process_existing_files (const char* report_dir) { GDir* dir = NULL; const gchar* file = NULL; @@ -651,10 +654,10 @@ char* upload_file = NULL; char* crash_file = NULL; - dir = g_dir_open ("/var/crash", 0, NULL); + dir = g_dir_open (report_dir, 0, NULL); while ((file = g_dir_read_name (dir)) != NULL) { - upload_file = g_build_filename ("/var/crash", file, NULL); + upload_file = g_build_filename (report_dir, file, NULL); if (!upload_file) continue; @@ -671,8 +674,7 @@ } if (already_handled_report (crash_file)) { - if (!mark_handled (crash_file)) - g_print ("Unable to mark report as seen (%s)\n", crash_file); + continue; } else if (online_state && parse_and_upload_report (crash_file)) { if (!mark_handled (crash_file)) g_print ("Unable to mark report as seen (%s)\n", crash_file); @@ -830,7 +832,7 @@ online_state = available; if (online_state) - process_existing_files (); + process_existing_files (report_dir); } gboolean @@ -894,9 +896,9 @@ exit (EXIT_FAILURE); } - monitor_directory ("/var/crash", check_online_then_upload); + monitor_directory (report_dir, check_online_then_upload); monitor_connectivity (crash_db_url, network_changed); - process_existing_files (); + process_existing_files (report_dir); g_timeout_add_seconds (PROCESS_OUTSTANDING_TIMEOUT, (GSourceFunc) process_existing_files, NULL); diff -Nru whoopsie-0.2.7/src/whoopsie.h whoopsie-0.2.7.1/src/whoopsie.h --- whoopsie-0.2.7/src/whoopsie.h 2012-05-15 17:54:18.000000000 +0000 +++ whoopsie-0.2.7.1/src/whoopsie.h 2012-12-14 00:26:26.000000000 +0000 @@ -24,5 +24,6 @@ char* get_crash_db_url (void); void destroy_key_and_value (gpointer key, gpointer value, gpointer user_data); void drop_privileges (GError** error); +void process_existing_files (const char* report_dir); #endif /* WHOOPSIE_H */