diff options
author | jstebbins <[email protected]> | 2008-10-31 23:29:38 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2008-10-31 23:29:38 +0000 |
commit | a1e5d59b8fa5eb8b46a34bf120f6a70e4c1d5608 (patch) | |
tree | 03549b1b939c5f90ee44de6699dcd473b21f316f /gtk/src | |
parent | 2ff0ad590ea9f4c559ecbcf24282d8d9559aa61d (diff) |
LinGui: purge old activity logs that are older than 1 week
this only applies to logs stored in the users config dir
logs that are stored in the movies destination directory are never purged
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1888 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r-- | gtk/src/callbacks.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c index f79fbe24e..644d76548 100644 --- a/gtk/src/callbacks.c +++ b/gtk/src/callbacks.c @@ -40,6 +40,7 @@ static void update_chapter_list(signal_user_data_t *ud); static GList* dvd_device_list(); +static void prune_logs(signal_user_data_t *ud); // This is a dependency map used for greying widgets // that are dependent on the state of another widget. @@ -254,12 +255,14 @@ on_quit1_activate(GtkMenuItem *quit, signal_user_data_t *ud) if (ghb_cancel_encode("Closing HandBrake will terminate encoding.\n")) { ghb_hb_cleanup(FALSE); + prune_logs(ud); gtk_main_quit(); return; } return; } ghb_hb_cleanup(FALSE); + prune_logs(ud); gtk_main_quit(); } @@ -603,6 +606,7 @@ ghb_do_scan(signal_user_data_t *ud, const gchar *filename, gboolean force) gtk_progress_bar_set_fraction (progress, 0); gtk_progress_bar_set_text (progress, "Scanning ..."); ghb_hb_cleanup(TRUE); + prune_logs(ud); ghb_backend_scan (path, 0); g_free(path); } @@ -829,6 +833,7 @@ window_destroy_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t * { g_debug("window_destroy_event_cb ()"); ghb_hb_cleanup(FALSE); + prune_logs(ud); gtk_main_quit(); return FALSE; } @@ -843,12 +848,14 @@ window_delete_event_cb(GtkWidget *widget, GdkEvent *event, signal_user_data_t *u if (ghb_cancel_encode("Closing HandBrake will terminate encoding.\n")) { ghb_hb_cleanup(FALSE); + prune_logs(ud); gtk_main_quit(); return FALSE; } return TRUE; } ghb_hb_cleanup(FALSE); + prune_logs(ud); gtk_main_quit(); return FALSE; } @@ -1423,6 +1430,41 @@ submit_job(GValue *settings) } static void +prune_logs(signal_user_data_t *ud) +{ + gchar *dest_dir; + + // Only prune logs stored in the default config dir location + dest_dir = ghb_get_user_config_dir("EncodeLogs"); + if (g_file_test(dest_dir, G_FILE_TEST_IS_DIR)) + { + const gchar *file; + int week = 7*24*60*60; + GDir *gdir = g_dir_open(dest_dir, 0, NULL); + time_t now; + + now = time(NULL); + file = g_dir_read_name(gdir); + while (file) + { + gchar *path; + struct stat stbuf; + + path = g_strdup_printf("%s/%s", dest_dir, file); + g_stat(path, &stbuf); + if (now - stbuf.st_mtime > week) + { + g_unlink(path); + } + g_free(path); + file = g_dir_read_name(gdir); + } + g_dir_close(gdir); + } + g_free(dest_dir); +} + +static void queue_scan(signal_user_data_t *ud, GValue *js) { gchar *path; @@ -2484,11 +2526,13 @@ drive_changed_cb(GVolumeMonitor *gvm, GDrive *gd, signal_user_data_t *ud) gtk_progress_bar_set_fraction (progress, 0); update_source_label(ud, device); ghb_hb_cleanup(TRUE); + prune_logs(ud); ghb_backend_scan(device, 0); } else { ghb_hb_cleanup(TRUE); + prune_logs(ud); ghb_backend_scan("/dev/null", 0); } } |