void terminate_dird(int sig);
static bool check_resources();
static void dir_sql_query(JCR *jcr, const char *cmd);
+static void cleanup_old_files();
/* Exported subroutines */
extern "C" void reload_config(int sig);
drop(uid, gid, false); /* reduce privileges if requested */
+ cleanup_old_files();
+
/* If we are in testing mode, we don't try to fix the catalog */
cat_op mode=(test_config)?CHECK_CONNECTION:UPDATE_AND_FIX;
db_sql_query(db, cleanup_running_job, NULL, NULL);
}
+ /* Set type in global for debugging */
+ set_db_type(db_get_type(db));
+
db_close_database(NULL, db);
}
return OK;
}
+
+static void copy_base_name(POOLMEM *cleanup)
+{
+ int len = strlen(director->working_directory);
+#if defined(HAVE_WIN32)
+ pm_strcpy(cleanup, "del /q ");
+#else
+ pm_strcpy(cleanup, "/bin/rm -f ");
+#endif
+ pm_strcat(cleanup, director->working_directory);
+ if (len > 0 && !IsPathSeparator(director->working_directory[len-1])) {
+ pm_strcat(cleanup, "/");
+ }
+ pm_strcat(cleanup, my_name);
+}
+
+static void cleanup_old_files()
+{
+ POOLMEM *cleanup = get_pool_memory(PM_MESSAGE);
+ POOLMEM *results = get_pool_memory(PM_MESSAGE);
+ copy_base_name(cleanup);
+ pm_strcat(cleanup, "*.restore.*.bsr");
+ run_program(cleanup, 0, results);
+ copy_base_name(cleanup);
+ pm_strcat(cleanup, "*.mail");
+ run_program(cleanup, 0, results);
+ free_pool_memory(cleanup);
+ free_pool_memory(results);
+}