Add FileManager::delete_partial_remote_location_if_needed.
This commit is contained in:
parent
4a64803805
commit
c46af3318d
@ -243,9 +243,7 @@ class UploadBackgroundQuery final : public Td::ResultHandler {
|
||||
// TODO td_->background_manager_->on_upload_background_file_parts_missing(file_id_, std::move(bad_parts));
|
||||
// return;
|
||||
} else {
|
||||
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id_, status);
|
||||
}
|
||||
td_->file_manager_->cancel_upload(file_id_);
|
||||
promise_.set_error(std::move(status));
|
||||
|
@ -309,11 +309,7 @@ class BusinessConnectionManager::UploadBusinessMediaQuery final : public Td::Res
|
||||
delete_thumbnail();
|
||||
|
||||
auto file_id = get_message_file_id(message_);
|
||||
if (status.code() != 429 && status.code() < 500) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id);
|
||||
} else {
|
||||
send_closure_later(G()->file_manager(), &FileManager::cancel_upload, file_id);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id, status);
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
@ -562,10 +562,10 @@ class UploadProfilePhotoQuery final : public Td::ResultHandler {
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
promise_.set_error(std::move(status));
|
||||
if (file_id_.is_valid()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
promise_.set_error(std::move(status));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3093,9 +3093,7 @@ class SendMediaQuery final : public Td::ResultHandler {
|
||||
td_->messages_manager_->on_send_message_file_parts_missing(random_id_, std::move(bad_parts));
|
||||
return;
|
||||
} else {
|
||||
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id_, status);
|
||||
}
|
||||
} else if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(status)) {
|
||||
if (file_id_.is_valid() && !was_uploaded_) {
|
||||
@ -3184,9 +3182,7 @@ class UploadMediaQuery final : public Td::ResultHandler {
|
||||
std::move(bad_parts));
|
||||
return;
|
||||
} else {
|
||||
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id_, status);
|
||||
}
|
||||
} else if (FileReferenceManager::is_file_reference_error(status)) {
|
||||
LOG(ERROR) << "Receive file reference error for UploadMediaQuery";
|
||||
@ -12569,9 +12565,7 @@ void MessagesManager::on_send_secret_message_error(int64 random_id, Status error
|
||||
return;
|
||||
}
|
||||
|
||||
if (error.code() != 429 && error.code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -25287,9 +25281,7 @@ void MessagesManager::on_message_media_edited(DialogId dialog_id, MessageId mess
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.error().code() != 429 && result.error().code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id, result.error());
|
||||
} else if (!td_->auth_manager_->is_bot() && FileReferenceManager::is_file_reference_error(result.error())) {
|
||||
if (file_id.is_valid()) {
|
||||
VLOG(file_references) << "Receive " << result.error() << " for " << file_id;
|
||||
|
@ -981,9 +981,7 @@ class UploadStickerFileQuery final : public Td::ResultHandler {
|
||||
// TODO td_->stickers_manager_->on_upload_sticker_file_parts_missing(file_id_, std::move(bad_parts));
|
||||
// return;
|
||||
} else {
|
||||
if (status.code() != 429 && status.code() < 500 && !G()->close_flag()) {
|
||||
td_->file_manager_->delete_partial_remote_location(file_id_);
|
||||
}
|
||||
td_->file_manager_->delete_partial_remote_location_if_needed(file_id_, status);
|
||||
}
|
||||
} else if (FileReferenceManager::is_file_reference_error(status)) {
|
||||
LOG(ERROR) << "Receive file reference error for UploadStickerFileQuery";
|
||||
|
@ -2857,6 +2857,14 @@ bool FileManager::delete_partial_remote_location(FileId file_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileManager::delete_partial_remote_location_if_needed(FileId file_id, const Status &error) {
|
||||
if (error.code() != 429 && error.code() < 500 && !G()->close_flag()) {
|
||||
delete_partial_remote_location(file_id);
|
||||
} else {
|
||||
cancel_upload(file_id);
|
||||
}
|
||||
}
|
||||
|
||||
void FileManager::delete_file_reference(FileId file_id, Slice file_reference) {
|
||||
VLOG(file_references) << "Delete file reference of file " << file_id << " "
|
||||
<< tag("reference_base64", base64_encode(file_reference));
|
||||
|
@ -495,6 +495,7 @@ class FileManager final : public FileLoadManager::Callback {
|
||||
int32 new_priority, uint64 upload_order, bool force = false, bool prefer_small = false);
|
||||
void cancel_upload(FileId file_id);
|
||||
bool delete_partial_remote_location(FileId file_id);
|
||||
void delete_partial_remote_location_if_needed(FileId file_id, const Status &error);
|
||||
void delete_file_reference(FileId file_id, Slice file_reference);
|
||||
void get_content(FileId file_id, Promise<BufferSlice> promise);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user