tg_cli: do not generate file when closing.

GitOrigin-RevId: 2cb23d3d15fca315993449a0033b7202e11dd90f
This commit is contained in:
levlam 2018-01-05 17:45:17 +03:00
parent 149c3fdc46
commit 0912cf4573
3 changed files with 9 additions and 2 deletions

View File

@ -550,6 +550,7 @@ class CliClient final : public Actor {
void quit() {
LOG(WARNING) << "QUIT";
close_flag_ = true;
dump_memory_usage();
td_.reset();
#if TD_WINDOWS
@ -557,7 +558,6 @@ class CliClient final : public Actor {
#else
is_stdin_reader_stopped_ = true;
#endif
close_flag_ = true;
yield();
}
@ -2738,6 +2738,10 @@ class CliClient final : public Actor {
}
void timeout_expired() override {
if (close_flag_) {
return;
}
for (auto it = pending_file_generations.begin(); it != pending_file_generations.end();) {
auto left_size = it->size - it->local_size;
CHECK(left_size > 0);

View File

@ -141,6 +141,7 @@ class FileExternalGenerateActor : public FileGenerateActor {
if (local_.type_ == LocalFileLocation::Type::Partial) {
const auto &partial = local_.partial();
path_ = partial.path_;
LOG(INFO) << "Unlink partially generated file at " << path_;
unlink(path_).ignore();
} else {
auto r_file_path = open_temp_file(generate_location_.type_);
@ -191,6 +192,7 @@ class FileExternalGenerateActor : public FileGenerateActor {
}
if (status.is_error()) {
LOG(INFO) << "Unlink partially generated file at " << path_ << " because of " << status;
unlink(path_).ignore();
callback_->on_error(std::move(status));
callback_.reset();

View File

@ -1277,7 +1277,7 @@ void FileManager::delete_file(FileId file_id, Promise<Unit> promise, const char
// TODO: review delete condition
if (file_view.has_local_location()) {
if (begins_with(file_view.local_location().path_, get_files_dir(file_view.get_type()))) {
LOG(INFO) << "Delete file " << file_id << " at " << file_view.local_location().path_;
LOG(INFO) << "Unlink file " << file_id << " at " << file_view.local_location().path_;
clear_from_pmc(node);
unlink(file_view.local_location().path_).ignore();
@ -1290,6 +1290,7 @@ void FileManager::delete_file(FileId file_id, Promise<Unit> promise, const char
clear_from_pmc(node);
}
if (node->local_.type_ == LocalFileLocation::Type::Partial) {
LOG(INFO) << "Unlink partial file " << file_id << " at " << node->local_.partial().path_;
unlink(node->local_.partial().path_).ignore();
node->set_local_location(LocalFileLocation(), 0);
try_flush_node(node);