Skip to content

Commit

Permalink
ua-restore: add explicit parameter to InsertOneFileOrDir
Browse files Browse the repository at this point in the history
Instead of implicitly using ua->cmd, we instead pass the parameter
explicitly.
  • Loading branch information
sebsura authored and BareosBot committed Aug 23, 2023
1 parent 204cf68 commit 0340e5a
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions core/src/dird/ua_restore.cc
Expand Up @@ -84,6 +84,7 @@ static bool InsertDirIntoFindexList(UaContext* ua,
char* date);
static void InsertOneFileOrDir(UaContext* ua,
RestoreContext* rx,
char* p,
char* date,
bool dir);
static bool GetClientName(UaContext* ua, RestoreContext* rx);
Expand Down Expand Up @@ -591,15 +592,9 @@ static int UserSelectJobidsOrFiles(UaContext* ua, RestoreContext* rx)
if (!have_date) { bstrutime(date, sizeof(date), now); }
if (!GetClientName(ua, rx)) { return 0; }

for (auto* file : files) {
PmStrcpy(ua->cmd, file);
InsertOneFileOrDir(ua, rx, date, false);
}
for (auto& file : files) { InsertOneFileOrDir(ua, rx, file, date, false); }

for (auto* dir : dirs) {
PmStrcpy(ua->cmd, dir);
InsertOneFileOrDir(ua, rx, date, true);
}
for (auto& dir : dirs) { InsertOneFileOrDir(ua, rx, dir, date, true); }

return 2;
}
Expand Down Expand Up @@ -703,7 +698,7 @@ static int UserSelectJobidsOrFiles(UaContext* ua, RestoreContext* rx)
if (!GetCmd(ua, _("Enter full filename: "))) { return 0; }
len = strlen(ua->cmd);
if (len == 0) { break; }
InsertOneFileOrDir(ua, rx, date, false);
InsertOneFileOrDir(ua, rx, ua->cmd, date, false);
}
return 2;
case 7: /* enter files backed up before specified time */
Expand All @@ -719,7 +714,7 @@ static int UserSelectJobidsOrFiles(UaContext* ua, RestoreContext* rx)
if (!GetCmd(ua, _("Enter full filename: "))) { return 0; }
len = strlen(ua->cmd);
if (len == 0) { break; }
InsertOneFileOrDir(ua, rx, date, false);
InsertOneFileOrDir(ua, rx, ua->cmd, date, false);
}
return 2;

Expand Down Expand Up @@ -765,7 +760,7 @@ static int UserSelectJobidsOrFiles(UaContext* ua, RestoreContext* rx)
if (ua->cmd[0] != '<' && !IsPathSeparator(ua->cmd[len - 1])) {
strcat(ua->cmd, "/");
}
InsertOneFileOrDir(ua, rx, date, true);
InsertOneFileOrDir(ua, rx, ua->cmd, date, true);
}
return 2;

Expand Down Expand Up @@ -912,12 +907,12 @@ std::string CompensateShortDate(const char* cmd)
// Insert a single file, or read a list of files from a file
static void InsertOneFileOrDir(UaContext* ua,
RestoreContext* rx,
char* p,
char* date,
bool dir)
{
FILE* ffd;
char file[5000];
char* p = ua->cmd;
int line = 0;

switch (*p) {
Expand Down Expand Up @@ -950,9 +945,9 @@ static void InsertOneFileOrDir(UaContext* ua,
break;
default:
if (dir) {
InsertDirIntoFindexList(ua, rx, ua->cmd, date);
InsertDirIntoFindexList(ua, rx, p, date);
} else {
InsertFileIntoFindexList(ua, rx, ua->cmd, date);
InsertFileIntoFindexList(ua, rx, p, date);
}
break;
}
Expand Down

0 comments on commit 0340e5a

Please sign in to comment.