More fixes
This commit is contained in:
parent
54531202a8
commit
5c4e8bc0bd
@ -365,13 +365,13 @@ void FileReferenceManager::reload_photo(PhotoSizeSource source, Promise<Unit> pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileReferenceManager::memory_cleanup(FileId file_id) {
|
void FileReferenceManager::memory_cleanup(NodeId node_id) {
|
||||||
auto find_node = nodes_.find(file_id);
|
auto find_node = nodes_.find(node_id);
|
||||||
if (find_node != nodes_.end()) {
|
if (find_node != nodes_.end()) {
|
||||||
auto &node = find_node->second;
|
auto &node = find_node->second;
|
||||||
node.query.reset();
|
node.query.reset();
|
||||||
node.file_source_ids.reset_position();
|
node.file_source_ids.reset_position();
|
||||||
nodes_.erase(file_id);
|
nodes_.erase(node_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,6 @@ class FileReferenceManager : public Actor {
|
|||||||
static bool is_file_reference_error(const Status &error);
|
static bool is_file_reference_error(const Status &error);
|
||||||
static size_t get_file_reference_error_pos(const Status &error);
|
static size_t get_file_reference_error_pos(const Status &error);
|
||||||
|
|
||||||
void memory_cleanup(FileId file_id);
|
|
||||||
|
|
||||||
FileSourceId create_message_file_source(FullMessageId full_message_id);
|
FileSourceId create_message_file_source(FullMessageId full_message_id);
|
||||||
FileSourceId create_user_photo_file_source(UserId user_id, int64 photo_id);
|
FileSourceId create_user_photo_file_source(UserId user_id, int64 photo_id);
|
||||||
// file reference aren't used for chat/channel photo download and the photos can't be reused
|
// file reference aren't used for chat/channel photo download and the photos can't be reused
|
||||||
@ -74,6 +72,8 @@ class FileReferenceManager : public Actor {
|
|||||||
template <class ParserT>
|
template <class ParserT>
|
||||||
FileSourceId parse_file_source(Td *td, ParserT &parser);
|
FileSourceId parse_file_source(Td *td, ParserT &parser);
|
||||||
|
|
||||||
|
void memory_cleanup(NodeId node_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Destination {
|
struct Destination {
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#define FILE_TTL 120
|
#define FILE_TTL 30
|
||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
namespace {
|
namespace {
|
||||||
@ -1032,7 +1032,7 @@ bool FileManager::try_fix_partial_local_location(FileNodePtr node) {
|
|||||||
|
|
||||||
FileManager::FileIdInfo *FileManager::get_file_id_info(FileId file_id) {
|
FileManager::FileIdInfo *FileManager::get_file_id_info(FileId file_id) {
|
||||||
file_id.set_time();
|
file_id.set_time();
|
||||||
return &file_id_info_[file_id.get()];
|
return &file_id_info_.at(file_id.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
FileId FileManager::dup_file_id(FileId file_id) {
|
FileId FileManager::dup_file_id(FileId file_id) {
|
||||||
@ -1073,6 +1073,9 @@ void FileManager::try_forget_file_id(FileId file_id) {
|
|||||||
CHECK(is_removed);
|
CHECK(is_removed);
|
||||||
*info = FileIdInfo();
|
*info = FileIdInfo();
|
||||||
file_id_info_.erase(file_id.get());
|
file_id_info_.erase(file_id.get());
|
||||||
|
// Start custom-patches
|
||||||
|
context_->destroy_file_source(file_id);
|
||||||
|
// End custom-patches
|
||||||
}
|
}
|
||||||
|
|
||||||
FileId FileManager::register_empty(FileType type) {
|
FileId FileManager::register_empty(FileType type) {
|
||||||
@ -1909,14 +1912,22 @@ FileNode *FileManager::get_file_node_raw(FileId file_id, FileNodeId *file_node_i
|
|||||||
if (file_id.get() <= 0) {
|
if (file_id.get() <= 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
FileNodeId node_id = file_id_info_[file_id.get()].node_id_;
|
auto find_file_id_info = file_id_info_.find(file_id.get());
|
||||||
|
if (find_file_id_info == file_id_info_.end()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
FileNodeId node_id = find_file_id_info->second.node_id_;
|
||||||
if (node_id == 0) {
|
if (node_id == 0) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
auto find_file_nodes = file_nodes_.find(node_id);
|
||||||
|
if (find_file_nodes == file_nodes_.end()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if (file_node_id != nullptr) {
|
if (file_node_id != nullptr) {
|
||||||
*file_node_id = node_id;
|
*file_node_id = node_id;
|
||||||
}
|
}
|
||||||
return file_nodes_[node_id].get();
|
return find_file_nodes->second.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNodePtr FileManager::get_sync_file_node(FileId file_id) {
|
FileNodePtr FileManager::get_sync_file_node(FileId file_id) {
|
||||||
|
Loading…
Reference in New Issue
Block a user