static void insert_one_file_or_dir(UAContext *ua, RESTORE_CTX *rx, char *date, bool dir);
static int get_client_name(UAContext *ua, RESTORE_CTX *rx);
static int get_date(UAContext *ua, char *date, int date_len);
-static int count_handler(void *ctx, int num_fields, char **row);
+static int restore_count_handler(void *ctx, int num_fields, char **row);
static bool insert_table_into_findex_list(UAContext *ua, RESTORE_CTX *rx, char *table);
/*
char *p;
char date[MAX_TIME_LENGTH];
bool have_date = false;
+ /* Include current second if using current time */
+ utime_t now = time(NULL) + 1;
JobId_t JobId;
JOB_DBR jr = { (JobId_t)-1 };
bool done = false;
done = true;
break;
case 1: /* current */
- bstrutime(date, sizeof(date), time(NULL));
+ /*
+ * Note, we add one second here just to include any job
+ * that may have finished within the current second,
+ * which happens a lot in scripting small jobs.
+ */
+ bstrutime(date, sizeof(date), now);
have_date = true;
break;
case 2: /* before */
return 0;
}
if (!have_date) {
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
}
if (!get_client_name(ua, rx)) {
return 0;
return 2;
case 5: /* select */
if (!have_date) {
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
}
if (!select_backups_before_date(ua, rx, date)) {
return 0;
done = false;
break;
case 4: /* Select the most recent backups */
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
if (!select_backups_before_date(ua, rx, date)) {
return 0;
}
}
break;
case 6: /* Enter files */
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
if (!get_client_name(ua, rx)) {
return 0;
}
return 2;
case 8: /* Find JobIds for current backup */
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
if (!select_backups_before_date(ua, rx, date)) {
return 0;
}
if (*rx->JobIds == 0 || *rx->JobIds == '.') {
return 0; /* nothing entered, return */
}
- bstrutime(date, sizeof(date), time(NULL));
+ bstrutime(date, sizeof(date), now);
if (!get_client_name(ua, rx)) {
return 0;
}
if (get_next_jobid_from_list(&p, &JobId) > 0) {
/* Use first JobId as estimate of the number of files to restore */
Mmsg(rx->query, uar_count_files, edit_int64(JobId, ed1));
- if (!db_sql_query(ua->db, rx->query, count_handler, (void *)rx)) {
+ if (!db_sql_query(ua->db, rx->query, restore_count_handler, (void *)rx)) {
ua->error_msg("%s\n", db_strerror(ua->db));
}
if (rx->found) {
return 1;
}
-static int count_handler(void *ctx, int num_fields, char **row)
+static int restore_count_handler(void *ctx, int num_fields, char **row)
{
RESTORE_CTX *rx = (RESTORE_CTX *)ctx;
rx->JobId = str_to_int64(row[0]);