| 4229 | } |
| 4230 | |
| 4231 | static void |
| 4232 | prune_logs (void) |
| 4233 | { |
| 4234 | gchar *dest_dir; |
| 4235 | gint days; |
| 4236 | signal_user_data_t *ud = ghb_ud(); |
| 4237 | |
| 4238 | // Only prune logs stored in the default config dir location |
| 4239 | days = ghb_settings_combo_int(ud->prefs, "LogLongevity"); |
| 4240 | if (days > 365) |
| 4241 | return; |
| 4242 | |
| 4243 | dest_dir = ghb_get_user_config_dir("EncodeLogs"); |
| 4244 | if (g_file_test(dest_dir, G_FILE_TEST_IS_DIR)) |
| 4245 | { |
| 4246 | const gchar *file; |
| 4247 | gint duration = days * 24 * 60 * 60; |
| 4248 | |
| 4249 | GDir *gdir = g_dir_open(dest_dir, 0, NULL); |
| 4250 | time_t now; |
| 4251 | |
| 4252 | now = time(NULL); |
| 4253 | file = g_dir_read_name(gdir); |
| 4254 | while (file) |
| 4255 | { |
| 4256 | gchar *path; |
| 4257 | GStatBuf stbuf; |
| 4258 | |
| 4259 | path = g_strdup_printf("%s/%s", dest_dir, file); |
| 4260 | g_stat(path, &stbuf); |
| 4261 | if (now - stbuf.st_mtime > duration) |
| 4262 | { |
| 4263 | g_unlink(path); |
| 4264 | } |
| 4265 | g_free(path); |
| 4266 | file = g_dir_read_name(gdir); |
| 4267 | } |
| 4268 | g_dir_close(gdir); |
| 4269 | } |
| 4270 | g_free(dest_dir); |
| 4271 | ghb_preview_cleanup(ud); |
| 4272 | } |
| 4273 | |
| 4274 | static gint |
| 4275 | queue_pending_count(GhbValue *queue) |
no test coverage detected