Use the exact file size instead of the real file size in fast storage statistics on Windows, because the real file size is smaller then expected before the file is synced.
GitOrigin-RevId: 451231c899c1b6c6b80b46e2cb42bd3b94def0a5
This commit is contained in:
parent
58dc8dd207
commit
9862652e14
@ -42,13 +42,19 @@ void StorageManager::start_up() {
|
||||
load_fast_stat();
|
||||
}
|
||||
|
||||
void StorageManager::on_new_file(int64 size, int32 cnt) {
|
||||
LOG(INFO) << "Add " << cnt << " file of size " << size << " to fast storage statistics";
|
||||
void StorageManager::on_new_file(int64 size, int64 real_size, int32 cnt) {
|
||||
LOG(INFO) << "Add " << cnt << " file of size " << size << " with real size " << real_size
|
||||
<< " to fast storage statistics";
|
||||
fast_stat_.cnt += cnt;
|
||||
fast_stat_.size += size;
|
||||
#if TD_WINDOWS
|
||||
auto add_size = size;
|
||||
#else
|
||||
auto add_size = real_size;
|
||||
#endif
|
||||
fast_stat_.size += add_size;
|
||||
|
||||
if (fast_stat_.cnt < 0 || fast_stat_.size < 0) {
|
||||
LOG(ERROR) << "Wrong fast stat after adding size " << size << " and cnt " << cnt;
|
||||
LOG(ERROR) << "Wrong fast stat after adding size " << add_size << " and cnt " << cnt;
|
||||
fast_stat_ = FileTypeStat();
|
||||
}
|
||||
save_fast_stat();
|
||||
|
@ -38,7 +38,7 @@ class StorageManager : public Actor {
|
||||
void run_gc(FileGcParameters parameters, Promise<FileStats> promise);
|
||||
void update_use_storage_optimizer();
|
||||
|
||||
void on_new_file(int64 size, int32 cnt);
|
||||
void on_new_file(int64 size, int64 real_size, int32 cnt);
|
||||
|
||||
private:
|
||||
static constexpr uint32 GC_EACH = 60 * 60 * 24; // 1 day
|
||||
|
@ -4178,8 +4178,8 @@ void Td::init_file_manager() {
|
||||
explicit FileManagerContext(Td *td) : td_(td) {
|
||||
}
|
||||
|
||||
void on_new_file(int64 size, int32 cnt) final {
|
||||
send_closure(G()->storage_manager(), &StorageManager::on_new_file, size, cnt);
|
||||
void on_new_file(int64 size, int64 real_size, int32 cnt) final {
|
||||
send_closure(G()->storage_manager(), &StorageManager::on_new_file, size, real_size, cnt);
|
||||
}
|
||||
|
||||
void on_file_updated(FileId file_id) final {
|
||||
|
@ -2020,7 +2020,7 @@ void FileManager::delete_file(FileId file_id, Promise<Unit> promise, const char
|
||||
LOG(INFO) << "Unlink file " << file_id << " at " << file_view.local_location().path_;
|
||||
clear_from_pmc(node);
|
||||
|
||||
context_->on_new_file(-file_view.get_allocated_local_size(), -1);
|
||||
context_->on_new_file(-file_view.size(), -file_view.get_allocated_local_size(), -1);
|
||||
unlink(file_view.local_location().path_).ignore();
|
||||
node->drop_local_location();
|
||||
try_flush_node(node, "delete_file 1");
|
||||
@ -3272,7 +3272,7 @@ void FileManager::on_download_ok(QueryId query_id, const FullLocalFileLocation &
|
||||
LOG(ERROR) << "Can't register local file after download: " << r_new_file_id.error();
|
||||
} else {
|
||||
if (is_new) {
|
||||
context_->on_new_file(get_file_view(r_new_file_id.ok()).get_allocated_local_size(), 1);
|
||||
context_->on_new_file(size, get_file_view(r_new_file_id.ok()).get_allocated_local_size(), 1);
|
||||
}
|
||||
LOG_STATUS(merge(r_new_file_id.ok(), file_id));
|
||||
}
|
||||
@ -3439,7 +3439,7 @@ void FileManager::on_generate_ok(QueryId query_id, const FullLocalFileLocation &
|
||||
|
||||
FileView file_view(file_node);
|
||||
if (!file_view.has_generate_location() || !begins_with(file_view.generate_location().conversion_, "#file_id#")) {
|
||||
context_->on_new_file(file_view.get_allocated_local_size(), 1);
|
||||
context_->on_new_file(file_view.size(), file_view.get_allocated_local_size(), 1);
|
||||
}
|
||||
|
||||
run_upload(file_node, {});
|
||||
|
@ -361,7 +361,7 @@ class FileManager : public FileLoadManager::Callback {
|
||||
|
||||
class Context {
|
||||
public:
|
||||
virtual void on_new_file(int64 size, int32 cnt) = 0;
|
||||
virtual void on_new_file(int64 size, int64 real_size, int32 cnt) = 0;
|
||||
|
||||
virtual void on_file_updated(FileId size) = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user