Commit 877a6184 authored by puasonych's avatar puasonych

Update step logger

Fixed bugs with multithreading and added protection against data lost with insufficiently accurate setting of the maximum value of the file size
parent eb2118c1
...@@ -99,8 +99,11 @@ public: ...@@ -99,8 +99,11 @@ public:
_file_helper.open(_current_filename); _file_helper.open(_current_filename);
_current_size = _file_helper.size(); // expensive. called only once _current_size = _file_helper.size(); // expensive. called only once
_current_size += _file_header.formatted.size(); if (!_current_size)
if (_current_size) _file_helper.write(_file_header); {
_current_size += _file_header.formatted.size();
if (_current_size) _file_helper.write(_file_header);
}
} }
~step_file_sink() ~step_file_sink()
...@@ -123,14 +126,17 @@ protected: ...@@ -123,14 +126,17 @@ protected:
{ {
filename_t new_filename; filename_t new_filename;
std::tie(new_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext); std::tie(new_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext);
if (new_filename != _current_filename)
{ bool change_occured = !details::file_helper::file_exists(new_filename);
close_current_file(); if (change_occured) close_current_file();
// std::tie(_current_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext); _current_filename = std::move(new_filename);
_file_helper.open(_current_filename);
_tp = _next_tp();
_file_helper.open(_current_filename);
_tp = _next_tp();
if (change_occured)
{
_current_size = _file_header.formatted.size(); _current_size = _file_header.formatted.size();
if (_current_size) _file_helper.write(_file_header); if (_current_size) _file_helper.write(_file_header);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment