Skip to content

Commit

Permalink
refactor: fd_cmds.cc: extract sending include exclude items
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri authored and arogge committed Mar 2, 2023
1 parent 6263723 commit 69ce6c2
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions core/src/dird/fd_cmds.cc
Expand Up @@ -660,30 +660,37 @@ static void SendFilesetIgnoredir(JobControlRecord* jcr,
fd->fsend("Z %s\n", include_exclude_item->ignoredir.get(j));
}
}
// Send either an Included or an Excluded list to FD
static bool SendFileset(JobControlRecord* jcr)

static bool SendIncludeExcludeItems(JobControlRecord* jcr,
FilesetResource* fileset)
{
FilesetResource* fileset = jcr->dir_impl->res.fileset;
BareosSocket* fd = jcr->file_bsock;

for (auto include_item : fileset->include_items) {
fd->fsend("I\n");
SendFilesetIgnoredir(jcr, include_item);
SendFilesetOptions(jcr, include_item);
if (!SendFilesetFileAndPlugin(jcr, include_item)) {
jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
if (!SendFilesetFileAndPlugin(jcr, include_item)) { return false; }
}

for (auto exclude_item : fileset->exclude_items) {
fd->fsend("E\n");
SendFilesetIgnoredir(jcr, exclude_item);
SendFilesetOptions(jcr, exclude_item);
if (!SendFilesetFileAndPlugin(jcr, exclude_item)) {
jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}
if (!SendFilesetFileAndPlugin(jcr, exclude_item)) { return false; }
}

return true;
}

// Send either an Included or an Excluded list to FD
static bool SendFileset(JobControlRecord* jcr, FilesetResource* fileset)
{
BareosSocket* fd = jcr->file_bsock;

if (!SendIncludeExcludeItems(jcr, fileset)) {
jcr->setJobStatusWithPriorityCheck(JS_ErrorTerminated);
return false;
}

fd->signal(BNET_EOD); /* end of data */
Expand Down Expand Up @@ -778,7 +785,7 @@ bool SendIncludeExcludeLists(JobControlRecord* jcr)
if (jcr->dir_impl->res.fileset->new_include) {
fd->fsend(filesetcmd,
jcr->dir_impl->res.fileset->enable_vss ? " vss=1" : "");
return SendFileset(jcr);
return SendFileset(jcr, jcr->dir_impl->res.fileset);
}
return true;
}
Expand Down

0 comments on commit 69ce6c2

Please sign in to comment.