FileManager: try_flush_node_pmc

GitOrigin-RevId: dd087402d0339ca02979f96e1dbe32b8646ab4d1
This commit is contained in:
Arseny Smirnov 2019-01-30 20:40:23 +04:00
parent 2032f89723
commit 5203da0895
2 changed files with 10 additions and 6 deletions

View File

@ -1372,7 +1372,7 @@ void FileManager::add_file_source(FileId file_id, FileSourceId file_source_id) {
send_closure(G()->file_reference_manager(), &FileReferenceManager::add_file_source, node->main_file_id_, send_closure(G()->file_reference_manager(), &FileReferenceManager::add_file_source, node->main_file_id_,
file_source_id); file_source_id);
node->on_pmc_changed(); node->on_pmc_changed();
try_flush_node(node, "add_file_source"); try_flush_node_pmc(node, "add_file_source");
} }
void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id) { void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id) {
@ -1385,7 +1385,7 @@ void FileManager::remove_file_source(FileId file_id, FileSourceId file_source_id
send_closure(G()->file_reference_manager(), &FileReferenceManager::remove_file_source, node->main_file_id_, send_closure(G()->file_reference_manager(), &FileReferenceManager::remove_file_source, node->main_file_id_,
file_source_id); file_source_id);
node->on_pmc_changed(); node->on_pmc_changed();
try_flush_node(node, "remove_file_source"); try_flush_node_pmc(node, "remove_file_source");
} }
void FileManager::change_files_source(FileSourceId file_source_id, const vector<FileId> &old_file_ids, void FileManager::change_files_source(FileSourceId file_source_id, const vector<FileId> &old_file_ids,
@ -1438,6 +1438,11 @@ void FileManager::try_flush_node_full(FileNodePtr node, bool new_remote, bool ne
} }
void FileManager::try_flush_node(FileNodePtr node, const char *source) { void FileManager::try_flush_node(FileNodePtr node, const char *source) {
try_flush_node_pmc(node, source);
try_flush_node_info(node, source);
}
void FileManager::try_flush_node_pmc(FileNodePtr node, const char *source) {
if (node->need_pmc_flush()) { if (node->need_pmc_flush()) {
if (file_db_) { if (file_db_) {
load_from_pmc(node, true, true, true); load_from_pmc(node, true, true, true);
@ -1445,8 +1450,6 @@ void FileManager::try_flush_node(FileNodePtr node, const char *source) {
} }
node->on_pmc_flushed(); node->on_pmc_flushed();
} }
try_flush_node_info(node, source);
} }
void FileManager::try_flush_node_info(FileNodePtr node, const char *source) { void FileManager::try_flush_node_info(FileNodePtr node, const char *source) {
@ -1613,7 +1616,7 @@ bool FileManager::set_encryption_key(FileId file_id, FileEncryptionKey key) {
return false; return false;
} }
node->set_encryption_key(std::move(key)); node->set_encryption_key(std::move(key));
try_flush_node(node, "set_encryption_key"); try_flush_node_pmc(node, "set_encryption_key");
return true; return true;
} }
@ -1941,7 +1944,7 @@ void FileManager::delete_file_reference(FileId file_id, string file_reference) {
return; return;
} }
node->delete_file_reference(file_reference); node->delete_file_reference(file_reference);
try_flush_node(node, "delete_file_reference"); try_flush_node_pmc(node, "delete_file_reference");
} }
void FileManager::external_file_generate_progress(int64 id, int32 expected_size, int32 local_prefix_size, void FileManager::external_file_generate_progress(int64 id, int32 expected_size, int32 local_prefix_size,

View File

@ -507,6 +507,7 @@ class FileManager : public FileLoadManager::Callback {
void try_flush_node_full(FileNodePtr node, bool new_remote, bool new_local, bool new_generate, FileDbId other_pmc_id); void try_flush_node_full(FileNodePtr node, bool new_remote, bool new_local, bool new_generate, FileDbId other_pmc_id);
void try_flush_node(FileNodePtr node, const char *source); void try_flush_node(FileNodePtr node, const char *source);
void try_flush_node_info(FileNodePtr node, const char *source); void try_flush_node_info(FileNodePtr node, const char *source);
void try_flush_node_pmc(FileNodePtr node, const char *source);
void clear_from_pmc(FileNodePtr node); void clear_from_pmc(FileNodePtr node);
void flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate); void flush_to_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate);
void load_from_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate); void load_from_pmc(FileNodePtr node, bool new_remote, bool new_local, bool new_generate);