mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'pbcullen/topic/pbcullen/shadow-file-handling'
* pbcullen/topic/pbcullen/shadow-file-handling:
reformat changes
Gracefully handle empty/missing shadow file
(cherry picked from commit ad6d70d4e6
)
This commit is contained in:
parent
2ccded3beb
commit
e9decdccde
1 changed files with 13 additions and 7 deletions
|
@ -122,10 +122,14 @@ TEST_CASE("writers.ascii prefix_basename_with")
|
||||||
static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
||||||
{
|
{
|
||||||
auto sfname = prefix_basename_with(fname, shadow_file_prefix);
|
auto sfname = prefix_basename_with(fname, shadow_file_prefix);
|
||||||
|
string default_ext = "." + Ascii::LogExt();
|
||||||
|
if ( BifConst::LogAscii::gzip_level > 0 )
|
||||||
|
default_ext += ".gz";
|
||||||
|
|
||||||
LeftoverLog rval = {};
|
LeftoverLog rval = {};
|
||||||
rval.filename = fname;
|
rval.filename = fname;
|
||||||
rval.shadow_filename = std::move(sfname);
|
rval.shadow_filename = std::move(sfname);
|
||||||
|
rval.extension = default_ext;
|
||||||
|
|
||||||
auto sf_stream = fopen(rval.shadow_filename.data(), "r");
|
auto sf_stream = fopen(rval.shadow_filename.data(), "r");
|
||||||
|
|
||||||
|
@ -181,14 +185,16 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
||||||
|
|
||||||
if ( sf_lines.size() < 2 )
|
if ( sf_lines.size() < 2 )
|
||||||
{
|
{
|
||||||
rval.error = util::fmt("Found leftover log, '%s', but the associated shadow "
|
reporter->Warning("Found leftover log, '%s', but the associated shadow "
|
||||||
" file, '%s', required to process it is invalid",
|
" file, '%s', required to process it is invalid: using default "
|
||||||
rval.filename.data(), rval.shadow_filename.data());
|
" for extension (%s) and post_proc_func",
|
||||||
return rval;
|
rval.filename.data(), rval.shadow_filename.data(), default_ext.data());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rval.extension = sf_lines[0];
|
||||||
|
rval.post_proc_func = sf_lines[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
rval.extension = sf_lines[0];
|
|
||||||
rval.post_proc_func = sf_lines[1];
|
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue