summaryrefslogtreecommitdiff
path: root/src/mongo/db/ftdc/file_reader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ftdc/file_reader.cpp')
-rw-r--r--src/mongo/db/ftdc/file_reader.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mongo/db/ftdc/file_reader.cpp b/src/mongo/db/ftdc/file_reader.cpp
index 54b79151958..1b739879c9c 100644
--- a/src/mongo/db/ftdc/file_reader.cpp
+++ b/src/mongo/db/ftdc/file_reader.cpp
@@ -161,8 +161,8 @@ StatusWith<BSONObj> FTDCFileReader::readDocument() {
}
return {ErrorCodes::FileStreamFailed,
- str::stream() << "Failed to read 4 bytes from file \'" << _file.generic_string()
- << "\'"};
+ str::stream() << "Failed to read 4 bytes from file \"" << _file.generic_string()
+ << "\""};
}
std::uint32_t bsonLength = ConstDataView(buf).read<LittleEndian<std::int32_t>>();
@@ -176,8 +176,8 @@ StatusWith<BSONObj> FTDCFileReader::readDocument() {
// Reads past the end of the file will be caught below
if (bsonLength > _fileSize || bsonLength < BSONObj::kMinBSONLength) {
return {ErrorCodes::InvalidLength,
- str::stream() << "Invalid BSON length found in file \'" << _file.generic_string()
- << "\'"};
+ str::stream() << "Invalid BSON length found in file \"" << _file.generic_string()
+ << "\""};
}
// Read the BSON document
@@ -193,9 +193,9 @@ StatusWith<BSONObj> FTDCFileReader::readDocument() {
if (readSize != _stream.gcount()) {
return {ErrorCodes::FileStreamFailed,
- str::stream() << "Failed to read " << readSize << " bytes from file \'"
+ str::stream() << "Failed to read " << readSize << " bytes from file \""
<< _file.generic_string()
- << "\'"};
+ << "\""};
}
ConstDataRange cdr(_buffer.data(), _buffer.data() + bsonLength);
@@ -215,7 +215,14 @@ Status FTDCFileReader::open(const boost::filesystem::path& file) {
return Status(ErrorCodes::FileStreamFailed, "Failed to open file " + file.generic_string());
}
- _fileSize = boost::filesystem::file_size(file);
+ boost::system::error_code ec;
+ _fileSize = boost::filesystem::file_size(file, ec);
+ if (ec) {
+ return {ErrorCodes::NonExistentPath,
+ str::stream() << "\"" << file.generic_string()
+ << "\" file size could not be retrieved during open: "
+ << ec.message()};
+ }
_file = file;