in util/TransferLogManager.cpp [871:919]
ErrorCode LogParser::processFileResizeEntry(char *buf, int64_t size) {
if (!headerParsed_) {
WLOG(ERROR)
<< "Invalid log: File resize entry found before transfer log header";
return INVALID_LOG;
}
int64_t timestamp, seqId, fileSize;
if (!encoderDecoder_.decodeFileResizeEntry(buf, size, timestamp, seqId,
fileSize)) {
return INVALID_LOG;
}
if (parseOnly_) {
std::cout << getFormattedTimestamp(timestamp) << " File resized,"
<< " seq-id " << seqId << " new file-size " << fileSize
<< std::endl;
return OK;
}
if (options_.resume_using_dir_tree) {
WLOG(ERROR) << "Can not have a file resize entry in directory based "
"resumption mode "
<< seqId << " " << fileSize;
return INVALID_LOG;
}
auto it = fileInfoMap_.find(seqId);
if (it == fileInfoMap_.end()) {
WLOG(ERROR) << "File resize entry for unknown sequence-id " << seqId << " "
<< fileSize;
return INVALID_LOG;
}
FileChunksInfo &chunksInfo = it->second;
const string &fileName = chunksInfo.getFileName();
auto sizeIt = seqIdToSizeMap_.find(seqId);
WDT_CHECK(sizeIt != seqIdToSizeMap_.end());
if (fileSize < sizeIt->second) {
WLOG(ERROR) << "File size can not reduce during resizing " << fileName
<< " " << seqId << " " << fileSize << " " << sizeIt->second;
return INVALID_LOG;
}
if (options_.shouldPreallocateFiles() &&
fileSize > chunksInfo.getFileSize()) {
WLOG(ERROR) << "Size on the disk is less than the resized size for "
<< fileName << " seq-id " << seqId << " disk-size "
<< chunksInfo.getFileSize() << " resized-size " << fileSize;
return INVALID_LOG;
}
sizeIt->second = fileSize;
return OK;
}