Don't check full local locations after loading file from database.

This commit is contained in:
levlam 2022-06-24 14:59:42 +03:00
parent c4690c9ed3
commit 7153a17bd7

View File

@ -1177,8 +1177,9 @@ Result<FileId> FileManager::register_file(FileData &&data, FileLocationSource fi
bool has_remote = data.remote_.type() == RemoteFileLocation::Type::Full; bool has_remote = data.remote_.type() == RemoteFileLocation::Type::Full;
bool has_generate = data.generate_ != nullptr; bool has_generate = data.generate_ != nullptr;
if (data.local_.type() == LocalFileLocation::Type::Full && !force) { if (data.local_.type() == LocalFileLocation::Type::Full && !force) {
if (file_location_source == FileLocationSource::FromBinlog || bool is_from_database = file_location_source == FileLocationSource::FromBinlog ||
file_location_source == FileLocationSource::FromDatabase) { file_location_source == FileLocationSource::FromDatabase;
if (is_from_database) {
PathView path_view(data.local_.full().path_); PathView path_view(data.local_.full().path_);
if (path_view.is_relative()) { if (path_view.is_relative()) {
data.local_.full().path_ = PSTRING() data.local_.full().path_ = PSTRING()
@ -1186,16 +1187,18 @@ Result<FileId> FileManager::register_file(FileData &&data, FileLocationSource fi
} }
} }
auto status = check_local_location(data.local_.full(), data.size_, skip_file_size_checks); if (!is_from_database) {
if (status.is_error()) { auto status = check_local_location(data.local_.full(), data.size_, skip_file_size_checks);
LOG(INFO) << "Invalid " << data.local_.full() << ": " << status << " from " << source; if (status.is_error()) {
data.local_ = LocalFileLocation(); LOG(INFO) << "Invalid " << data.local_.full() << ": " << status << " from " << source;
if (data.remote_.type() == RemoteFileLocation::Type::Partial) { data.local_ = LocalFileLocation();
data.remote_ = {}; if (data.remote_.type() == RemoteFileLocation::Type::Partial) {
} data.remote_ = {};
}
if (!has_remote && !has_generate) { if (!has_remote && !has_generate) {
return std::move(status); return std::move(status);
}
} }
} }
} }