Fix storage fast statistics after file checking.

GitOrigin-RevId: c912dc17c00ba61e1ad5b11bf6d411783fba58df
This commit is contained in:
levlam 2019-01-11 20:08:56 +03:00
parent 5ea6fda925
commit 15dda847f4
6 changed files with 15 additions and 13 deletions

View File

@ -134,7 +134,7 @@ Status FileDownloader::on_ok(int64 size) {
TRY_RESULT(perm_path, create_from_temp(path_, dir, name_));
path = std::move(perm_path);
}
callback_->on_ok(FullLocalFileLocation(remote_.file_type_, std::move(path), 0), size);
callback_->on_ok(FullLocalFileLocation(remote_.file_type_, std::move(path), 0), size, !only_check_);
return Status::OK();
}
void FileDownloader::on_error(Status status) {

View File

@ -29,7 +29,7 @@ class FileDownloader : public FileLoader {
public:
virtual void on_start_download() = 0;
virtual void on_partial_download(const PartialLocalFileLocation &partial_local, int64 ready_size, int64 size) = 0;
virtual void on_ok(const FullLocalFileLocation &full_local, int64 size) = 0;
virtual void on_ok(const FullLocalFileLocation &full_local, int64 size, bool is_new) = 0;
virtual void on_error(Status status) = 0;
};

View File

@ -220,14 +220,14 @@ void FileLoadManager::on_partial_upload(const PartialRemoteFileLocation &partial
}
}
void FileLoadManager::on_ok_download(const FullLocalFileLocation &local, int64 size) {
void FileLoadManager::on_ok_download(const FullLocalFileLocation &local, int64 size, bool is_new) {
auto node_id = get_link_token();
auto node = nodes_container_.get(node_id);
if (node == nullptr) {
return;
}
if (!stop_flag_) {
send_closure(callback_, &Callback::on_download_ok, node->query_id_, local, size);
send_closure(callback_, &Callback::on_download_ok, node->query_id_, local, size, is_new);
}
close_node(node_id);
loop();

View File

@ -42,7 +42,7 @@ class FileLoadManager final : public Actor {
virtual void on_hash(QueryId id, string hash) = 0;
virtual void on_upload_ok(QueryId id, FileType file_type, const PartialRemoteFileLocation &remtoe, int64 size) = 0;
virtual void on_upload_full_ok(QueryId id, const FullRemoteFileLocation &remote) = 0;
virtual void on_download_ok(QueryId id, const FullLocalFileLocation &local, int64 size) = 0;
virtual void on_download_ok(QueryId id, const FullLocalFileLocation &local, int64 size, bool is_new) = 0;
virtual void on_error(QueryId id, Status status) = 0;
};
@ -89,7 +89,7 @@ class FileLoadManager final : public Actor {
void on_partial_download(const PartialLocalFileLocation &partial_local, int64 ready_size, int64 size);
void on_partial_upload(const PartialRemoteFileLocation &partial_remote, int64 ready_size);
void on_hash(string hash);
void on_ok_download(const FullLocalFileLocation &local, int64 size);
void on_ok_download(const FullLocalFileLocation &local, int64 size, bool is_new);
void on_ok_upload(FileType file_type, const PartialRemoteFileLocation &remote, int64 size);
void on_ok_upload_full(const FullRemoteFileLocation &remote);
void on_error(Status status);
@ -109,8 +109,8 @@ class FileLoadManager final : public Actor {
void on_partial_download(const PartialLocalFileLocation &partial_local, int64 ready_size, int64 size) override {
send_closure(actor_id_, &FileLoadManager::on_partial_download, partial_local, ready_size, size);
}
void on_ok(const FullLocalFileLocation &full_local, int64 size) override {
send_closure(std::move(actor_id_), &FileLoadManager::on_ok_download, full_local, size);
void on_ok(const FullLocalFileLocation &full_local, int64 size, bool is_new) override {
send_closure(std::move(actor_id_), &FileLoadManager::on_ok_download, full_local, size, is_new);
}
void on_error(Status status) override {
send_closure(std::move(actor_id_), &FileLoadManager::on_error, std::move(status));
@ -163,7 +163,7 @@ class FileLoadManager final : public Actor {
ActorShared<FileLoadManager> actor_id_;
void on_ok(const FullLocalFileLocation &full_local, int64 size) override {
send_closure(std::move(actor_id_), &FileLoadManager::on_ok_download, full_local, size);
send_closure(std::move(actor_id_), &FileLoadManager::on_ok_download, full_local, size, true);
}
void on_error(Status status) override {
send_closure(std::move(actor_id_), &FileLoadManager::on_error, std::move(status));

View File

@ -2381,19 +2381,21 @@ void FileManager::on_partial_upload(QueryId query_id, const PartialRemoteFileLoc
try_flush_node(file_node, "on_partial_upload");
}
void FileManager::on_download_ok(QueryId query_id, const FullLocalFileLocation &local, int64 size) {
void FileManager::on_download_ok(QueryId query_id, const FullLocalFileLocation &local, int64 size, bool is_new) {
if (is_closed_) {
return;
}
auto query = finish_query(query_id).first;
auto file_id = query.file_id_;
LOG(INFO) << "ON DOWNLOAD OK file " << file_id << " of size " << size;
LOG(INFO) << "ON DOWNLOAD OK of " << (is_new ? "new" : "checked") << " file " << file_id << " of size " << size;
auto r_new_file_id = register_local(local, DialogId(), size);
if (r_new_file_id.is_error()) {
LOG(ERROR) << "Can't register local file after download: " << r_new_file_id.error();
} else {
if (is_new) {
context_->on_new_file(size, 1);
}
LOG_STATUS(merge(r_new_file_id.ok(), file_id));
}
}

View File

@ -502,7 +502,7 @@ class FileManager : public FileLoadManager::Callback {
int64 size) override;
void on_hash(QueryId query_id, string hash) override;
void on_partial_upload(QueryId query_id, const PartialRemoteFileLocation &partial_remote, int64 ready_size) override;
void on_download_ok(QueryId query_id, const FullLocalFileLocation &local, int64 size) override;
void on_download_ok(QueryId query_id, const FullLocalFileLocation &local, int64 size, bool is_new) override;
void on_upload_ok(QueryId query_id, FileType file_type, const PartialRemoteFileLocation &partial_remote,
int64 size) override;
void on_upload_full_ok(QueryId query_id, const FullRemoteFileLocation &remote) override;