FileManager.cpp: bugfix
GitOrigin-RevId: b075851e40beb6cafb7921055d4046bec26374eb
This commit is contained in:
parent
62d8e1fd40
commit
08c930e170
@ -698,6 +698,7 @@ Result<FileId> FileManager::register_file(FileData data, FileLocationSource file
|
|||||||
}
|
}
|
||||||
bool no_sync_merge = to_merge.size() == 1 && new_cnt == 0;
|
bool no_sync_merge = to_merge.size() == 1 && new_cnt == 0;
|
||||||
for (auto id : to_merge) {
|
for (auto id : to_merge) {
|
||||||
|
// may invalidate node
|
||||||
merge(file_id, id, no_sync_merge).ignore();
|
merge(file_id, id, no_sync_merge).ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1043,7 +1044,7 @@ void FileManager::try_flush_node(FileNode *node, bool new_remote, bool new_local
|
|||||||
FileDbId other_pmc_id) {
|
FileDbId other_pmc_id) {
|
||||||
if (node->need_pmc_flush()) {
|
if (node->need_pmc_flush()) {
|
||||||
if (file_db_) {
|
if (file_db_) {
|
||||||
load_from_pmc(node, true, true, true);
|
node = load_from_pmc(node, true, true, true);
|
||||||
flush_to_pmc(node, new_remote, new_local, new_generate);
|
flush_to_pmc(node, new_remote, new_local, new_generate);
|
||||||
if (other_pmc_id != 0 && node->pmc_id_ != other_pmc_id) {
|
if (other_pmc_id != 0 && node->pmc_id_ != other_pmc_id) {
|
||||||
file_db_->set_file_data_ref(other_pmc_id, node->pmc_id_);
|
file_db_->set_file_data_ref(other_pmc_id, node->pmc_id_);
|
||||||
@ -1155,20 +1156,17 @@ FileNode *FileManager::get_sync_file_node(FileId file_id, FileNodeId *file_node_
|
|||||||
if (!file_node) {
|
if (!file_node) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (load_from_pmc(file_node, true, true, true)) {
|
return load_from_pmc(file_node, true, true, true);
|
||||||
file_node = get_file_node(file_id, file_node_id);
|
|
||||||
}
|
|
||||||
return file_node;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileManager::load_from_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate) {
|
FileNode *FileManager::load_from_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate) {
|
||||||
if (!node->need_load_from_pmc_) {
|
if (!node->need_load_from_pmc_) {
|
||||||
return false;
|
return node;
|
||||||
}
|
}
|
||||||
auto file_id = node->main_file_id_;
|
auto file_id = node->main_file_id_;
|
||||||
node->need_load_from_pmc_ = false;
|
node->need_load_from_pmc_ = false;
|
||||||
if (!file_db_) {
|
if (!file_db_) {
|
||||||
return false;
|
return node;
|
||||||
}
|
}
|
||||||
auto file_view = get_file_view(file_id);
|
auto file_view = get_file_view(file_id);
|
||||||
|
|
||||||
@ -1192,7 +1190,8 @@ bool FileManager::load_from_pmc(FileNode *node, bool new_remote, bool new_local,
|
|||||||
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, register_file(std::move(file_data), FileLocationSource::FromDb, "load_from_pmc"));
|
TRY_RESULT(new_file_id, register_file(std::move(file_data), FileLocationSource::FromDb, "load_from_pmc"));
|
||||||
TRY_STATUS(merge(file_id, new_file_id));
|
TRY_RESULT(main_file_id, merge(file_id, new_file_id));
|
||||||
|
file_id = main_file_id;
|
||||||
return Status::OK();
|
return Status::OK();
|
||||||
};
|
};
|
||||||
if (new_remote) {
|
if (new_remote) {
|
||||||
@ -1204,7 +1203,7 @@ bool FileManager::load_from_pmc(FileNode *node, bool new_remote, bool new_local,
|
|||||||
if (new_generate) {
|
if (new_generate) {
|
||||||
load(generate);
|
load(generate);
|
||||||
}
|
}
|
||||||
return true;
|
return get_file_node(file_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileManager::set_encryption_key(FileId file_id, FileEncryptionKey key) {
|
bool FileManager::set_encryption_key(FileId file_id, FileEncryptionKey key) {
|
||||||
@ -2127,11 +2126,11 @@ void FileManager::on_generate_ok(QueryId query_id, const FullLocalFileLocation &
|
|||||||
status = result.move_as_error();
|
status = result.move_as_error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
file_node = get_file_node(generate_file_id);
|
||||||
if (status.is_error()) {
|
if (status.is_error()) {
|
||||||
return on_error_impl(file_node, query.type_, was_active, std::move(status));
|
return on_error_impl(file_node, query.type_, was_active, std::move(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
file_node = get_file_node(generate_file_id);
|
|
||||||
CHECK(file_node != nullptr);
|
CHECK(file_node != nullptr);
|
||||||
context_->on_new_file(FileView(file_node).size());
|
context_->on_new_file(FileView(file_node).size());
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ class FileManager : public FileLoadManager::Callback {
|
|||||||
void try_flush_node_info(FileNode *node);
|
void try_flush_node_info(FileNode *node);
|
||||||
void clear_from_pmc(FileNode *node);
|
void clear_from_pmc(FileNode *node);
|
||||||
void flush_to_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate);
|
void flush_to_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate);
|
||||||
bool load_from_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate);
|
FileNode *load_from_pmc(FileNode *node, bool new_remote, bool new_local, bool new_generate) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
string get_persistent_id(const FullRemoteFileLocation &location);
|
string get_persistent_id(const FullRemoteFileLocation &location);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user