This commit is contained in:
feng lv 2021-09-27 02:27:24 +00:00
parent da2c8f23cc
commit 69985ac4ae

View File

@ -349,23 +349,23 @@ void StorageFileLog::openFilesAndSetPos()
{ {
for (const auto & file : file_infos.file_names) for (const auto & file : file_infos.file_names)
{ {
auto & context = file_infos.context_by_name.at(file); auto & file_ctx = file_infos.context_by_name.at(file);
if (context.status != FileStatus::NO_CHANGE) if (file_ctx.status != FileStatus::NO_CHANGE)
{ {
context.reader = std::ifstream(getFullDataPath(file)); file_ctx.reader = std::ifstream(getFullDataPath(file));
if (!context.reader.good()) if (!file_ctx.reader.good())
{ {
throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Open file {} failed.", file); throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Open file {} failed.", file);
} }
context.reader.seekg(0, context.reader.end); file_ctx.reader.seekg(0, file_ctx.reader.end);
if (!context.reader.good()) if (!file_ctx.reader.good())
{ {
throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Seekg file {} failed.", file); throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Seekg file {} failed.", file);
} }
auto file_end = context.reader.tellg(); auto file_end = file_ctx.reader.tellg();
if (!context.reader.good()) if (!file_ctx.reader.good())
{ {
throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Tellg file {} failed.", file); throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Tellg file {} failed.", file);
} }
@ -378,8 +378,8 @@ void StorageFileLog::openFilesAndSetPos()
/// update file end at the monment, used in ReadBuffer and serialize /// update file end at the monment, used in ReadBuffer and serialize
meta.last_open_end = file_end; meta.last_open_end = file_end;
context.reader.seekg(meta.last_writen_position); file_ctx.reader.seekg(meta.last_writen_position);
if (!context.reader.good()) if (!file_ctx.reader.good())
{ {
throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Seekg file {} failed.", file); throw Exception(ErrorCodes::FILE_STREAM_ERROR, "Seekg file {} failed.", file);
} }