Synchronously load file in FileManager::add_file_source to avoid resaving it to the database.
This commit is contained in:
parent
6176272d60
commit
1e6a6c28af
@ -53,7 +53,7 @@ inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) {
|
|||||||
if (file_data.remote_.type() == RemoteFileLocation::Type::Full) {
|
if (file_data.remote_.type() == RemoteFileLocation::Type::Full) {
|
||||||
sb << " remote " << file_data.remote_.full();
|
sb << " remote " << file_data.remote_.full();
|
||||||
}
|
}
|
||||||
sb << format::as_array(file_data.file_source_ids_);
|
sb << ", sources = " << format::as_array(file_data.file_source_ids_);
|
||||||
return sb << "]";
|
return sb << "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,9 +68,9 @@ class FileDbInterface {
|
|||||||
Result<FileData> get_file_data_sync(const LocationT &location) {
|
Result<FileData> get_file_data_sync(const LocationT &location) {
|
||||||
auto res = get_file_data_sync_impl(as_key(location));
|
auto res = get_file_data_sync_impl(as_key(location));
|
||||||
if (res.is_ok()) {
|
if (res.is_ok()) {
|
||||||
LOG(DEBUG) << "GET " << location << " " << res.ok();
|
LOG(DEBUG) << "GET " << location << ": " << res.ok();
|
||||||
} else {
|
} else {
|
||||||
LOG(DEBUG) << "GET " << location << " " << res.error();
|
LOG(DEBUG) << "GET " << location << ": " << res.error();
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1742,7 +1742,7 @@ Result<FileId> FileManager::merge(FileId x_file_id, FileId y_file_id, bool no_sy
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::add_file_source(FileId file_id, FileSourceId file_source_id) {
|
void FileManager::add_file_source(FileId file_id, FileSourceId file_source_id) {
|
||||||
auto node = get_file_node(file_id);
|
auto node = get_sync_file_node(file_id); // synchronously load the file to preload known file sources
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1755,7 +1755,7 @@ void FileManager::add_file_source(FileId file_id, FileSourceId file_source_id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id) {
|
void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id) {
|
||||||
auto node = get_file_node(file_id);
|
auto node = get_sync_file_node(file_id); // synchronously load the file to preload known file sources
|
||||||
if (!node) {
|
if (!node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1992,8 +1992,8 @@ void FileManager::load_from_pmc(FileNodePtr node, bool new_remote, bool new_loca
|
|||||||
generate = file_view.generate_location();
|
generate = file_view.generate_location();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(DEBUG) << "Load from pmc " << file_id << "/" << file_view.get_main_file_id() << ", new_remote = " << new_remote
|
LOG(DEBUG) << "Load from pmc file " << file_id << '/' << file_view.get_main_file_id()
|
||||||
<< ", new_local = " << new_local << ", new_generate = " << new_generate;
|
<< ", new_remote = " << new_remote << ", new_local = " << new_local << ", new_generate = " << new_generate;
|
||||||
auto load = [&](auto location) {
|
auto load = [&](auto location) {
|
||||||
TRY_RESULT(file_data, file_db_->get_file_data_sync(location));
|
TRY_RESULT(file_data, file_db_->get_file_data_sync(location));
|
||||||
TRY_RESULT(new_file_id,
|
TRY_RESULT(new_file_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user