Delete self-destructed files if a message content was changed.
GitOrigin-RevId: 54c39a5a7ce014a3bc1f05c11d559ef2518b6bb0
This commit is contained in:
parent
51b3711171
commit
b61efbb40d
@ -21068,6 +21068,15 @@ MessagesManager::Message *MessagesManager::add_message_to_dialog(Dialog *d, uniq
|
|||||||
}
|
}
|
||||||
auto new_file_ids = get_message_content_file_ids((*v)->content.get(), td_);
|
auto new_file_ids = get_message_content_file_ids((*v)->content.get(), td_);
|
||||||
if (new_file_ids != old_file_ids) {
|
if (new_file_ids != old_file_ids) {
|
||||||
|
if ((*v)->ttl && (*v)->message_id.is_server()) {
|
||||||
|
for (auto file_id : old_file_ids) {
|
||||||
|
if (std::find(new_file_ids.begin(), new_file_ids.end(), file_id) == new_file_ids.end()) {
|
||||||
|
send_closure(G()->file_manager(), &FileManager::delete_file, file_id, Promise<>(),
|
||||||
|
"add_message_to_dialog");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, message_id));
|
auto file_source_id = get_message_file_source_id(FullMessageId(dialog_id, message_id));
|
||||||
if (file_source_id.is_valid()) {
|
if (file_source_id.is_valid()) {
|
||||||
td_->file_manager_->change_files_source(file_source_id, old_file_ids, new_file_ids);
|
td_->file_manager_->change_files_source(file_source_id, old_file_ids, new_file_ids);
|
||||||
@ -21672,8 +21681,7 @@ class MessagesManager::DeleteMessageLogEvent {
|
|||||||
|
|
||||||
void MessagesManager::delete_message_files(const Message *m) const {
|
void MessagesManager::delete_message_files(const Message *m) const {
|
||||||
for (auto file_id : get_message_file_ids(m)) {
|
for (auto file_id : get_message_file_ids(m)) {
|
||||||
send_closure(G()->file_manager(), &FileManager::delete_file, file_id, Promise<>(),
|
send_closure(G()->file_manager(), &FileManager::delete_file, file_id, Promise<>(), "delete_message_files");
|
||||||
"delete_message_files"); // TODO add log event
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,7 +1653,7 @@ void FileManager::delete_file(FileId file_id, Promise<Unit> promise, const char
|
|||||||
|
|
||||||
auto file_view = FileView(node);
|
auto file_view = FileView(node);
|
||||||
|
|
||||||
// TODO: review delete condition
|
// TODO review delete condition
|
||||||
if (file_view.has_local_location()) {
|
if (file_view.has_local_location()) {
|
||||||
if (begins_with(file_view.local_location().path_, get_files_dir(file_view.get_type()))) {
|
if (begins_with(file_view.local_location().path_, get_files_dir(file_view.get_type()))) {
|
||||||
LOG(INFO) << "Unlink file " << file_id << " at " << file_view.local_location().path_;
|
LOG(INFO) << "Unlink file " << file_id << " at " << file_view.local_location().path_;
|
||||||
|
Loading…
Reference in New Issue
Block a user