#include "amanda.h"
#include "match.h"
+#include "find.h"
#include "conffile.h"
#include "diskfile.h"
#include "tapefile.h"
#include "logfile.h"
#include "clock.h"
#include "holding.h"
-#include "driverio.h"
#include "server_util.h"
#include "timestamp.h"
GSList *datestamp_list = NULL;
config_overrides_t *cfg_ovr;
char **config_options;
+ find_result_t *holding_files;
+ disklist_t holding_disklist = { NULL, NULL };
/*
* Configure program for internationalization:
dbrename(get_config_name(), DBG_SUBDIR_SERVER);
+ /* load DLEs from the holding disk, in case there's anything to flush there */
+ search_holding_disk(&holding_files, &holding_disklist);
+ /* note that the dumps are added to the global disklist, so we need not
+ * consult holding_files or holding_disklist after this. The holding-only
+ * dumps will be filtered properly by match_disklist, setting the dp->todo
+ * flag appropriately. */
+
errstr = match_disklist(&diskq, argc-1, argv+1);
if (errstr) {
g_printf(_("%s"),errstr);
stralloc((char *)datestamp->data),
g_compare_strings);
}
- g_slist_free_full(all_datestamps);
+ slist_free_full(all_datestamps, g_free);
}
else {
/* otherwise, in batch mode, use all datestamps */
holding_file_get_dumpfile((char *)holding_file->data, &file);
if (holding_file_size((char *)holding_file->data, 1) <= 0) {
+ g_debug("%s is empty - ignoring", (char *)holding_file->data);
log_add(L_INFO, "%s: removing file with no data.",
(char *)holding_file->data);
holding_file_unlink((char *)holding_file->data);
continue;
}
+ /* search_holding_disk should have already ensured that every
+ * holding dumpfile has an entry in the dynamic disklist */
dp = lookup_disk(file.name, file.disk);
- if (!dp) {
- error("dp == NULL");
- /*NOTREACHED*/
- }
+ assert(dp != NULL);
+
+ /* but match_disklist may have indicated we should not flush it */
if (dp->todo == 0) continue;
qdisk = quote_string(file.disk);
file.datestamp,
file.dumplevel,
qhname);
+
+ g_debug("flushing '%s'", (char *)holding_file->data);
g_fprintf(driver_stream,
"FLUSH %s %s %s %d %s\n",
file.name,
}
}
- g_slist_free_full(datestamp_list);
+ slist_free_full(datestamp_list, g_free);
datestamp_list = NULL;
- g_slist_free_full(holding_list);
+ slist_free_full(holding_list, g_free);
holding_list = NULL;
if(redirect) { /* rename errfile */
}
chupper = (char)toupper(ch);
if (chupper < 'A' || chupper > max_char) {
- g_slist_free_full(r_datestamp_list);
+ slist_free_full(r_datestamp_list, g_free);
r_datestamp_list = NULL;
break;
}
stralloc(datestamps[chupper - 'A']));
} while ((ch = *a++) != '\0');
if (r_datestamp_list && ch == '\0') {
- g_slist_free_full(datestamp_list);
+ slist_free_full(datestamp_list, g_free);
datestamp_list = r_datestamp_list;
break;
}
}
g_printf(_("Ok, quitting. Run amflush again when you are ready.\n"));
+ log_add(L_INFO, "pid-done %ld", (long)getpid());
exit(1);
}
fflush(stdout); fflush(stderr);
errfile = vstralloc(conf_logdir, "/amflush", NULL);
- if((fderr = open(errfile, O_WRONLY| O_CREAT | O_TRUNC, 0600)) == -1) {
+ if((fderr = open(errfile, O_WRONLY| O_APPEND | O_CREAT | O_TRUNC, 0600)) == -1) {
error(_("could not open %s: %s"), errfile, strerror(errno));
/*NOTREACHED*/
}