Skip to content

Commit

Permalink
Conditionally disable FileInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Sep 16, 2024
1 parent 6d54b3a commit 91aa6c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions td/telegram/files/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,7 +1598,7 @@ FileId FileManager::register_empty(FileType type) {
file_id = next_file_id();

LOG(INFO) << "Register empty file as " << file_id;
auto file_info = td::make_unique<FileInfoLocal>(location, 0);
auto file_info = STORE_FILE_INFO ? td::make_unique<FileInfoLocal>(location, 0) : nullptr;
auto file_node_id = next_file_node_id();
file_nodes_[file_node_id] =
td::make_unique<FileNode>(LocalFileLocation(std::move(location)), NewRemoteFileLocation(), nullptr, 0, 0,
Expand Down Expand Up @@ -1642,7 +1642,7 @@ Result<FileId> FileManager::register_local(FullLocalFileLocation location, Dialo
file_id = next_file_id();
LOG(INFO) << "Register " << location << " as " << file_id;

auto file_info = td::make_unique<FileInfoLocal>(location, size);
auto file_info = STORE_FILE_INFO ? td::make_unique<FileInfoLocal>(location, size) : nullptr;
auto file_node_id = next_file_node_id();
auto &node = file_nodes_[file_node_id];
node = td::make_unique<FileNode>(LocalFileLocation(std::move(location)), NewRemoteFileLocation(), nullptr, size, 0,
Expand Down Expand Up @@ -1727,7 +1727,8 @@ FileId FileManager::register_remote(FullRemoteFileLocation location, FileLocatio
}

LOG(INFO) << "Register " << location << " as " << file_id;
auto file_info = td::make_unique<FileInfoRemote>(location, size, expected_size, remote_name, url);
auto file_info =
STORE_FILE_INFO ? td::make_unique<FileInfoRemote>(location, size, expected_size, remote_name, url) : nullptr;
auto file_node_id = next_file_node_id();
auto &node = file_nodes_[file_node_id];
node = td::make_unique<FileNode>(LocalFileLocation(),
Expand Down Expand Up @@ -1785,7 +1786,7 @@ FileId FileManager::do_register_generate(unique_ptr<FullGenerateFileLocation> ge

auto file_node_id = next_file_node_id();
auto &node = file_nodes_[file_node_id];
auto file_info = td::make_unique<FileInfoGenerate>(*generate, expected_size, url);
auto file_info = STORE_FILE_INFO ? td::make_unique<FileInfoGenerate>(*generate, expected_size, url) : nullptr;
node = td::make_unique<FileNode>(LocalFileLocation(), NewRemoteFileLocation(), std::move(generate), 0,
expected_size, string(), std::move(url), owner_dialog_id, FileEncryptionKey(),
file_id, static_cast<int8>(0));
Expand Down
2 changes: 2 additions & 0 deletions td/telegram/files/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,8 @@ class FileManager final : public Actor {
FileId parse_file(ParserT &parser);

private:
static constexpr bool STORE_FILE_INFO = false;

class FileDownloadManagerCallback final : public FileDownloadManager::Callback {
public:
explicit FileDownloadManagerCallback(ActorId<FileManager> actor_id) : actor_id_(std::move(actor_id)) {
Expand Down

0 comments on commit 91aa6c9

Please sign in to comment.