diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index 1f2e8b71..95c62e21 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -1146,10 +1146,17 @@ class FileData { } }; inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) { - sb << "[" << tag("name", file_data.name_); + sb << "[" << tag("name", file_data.name_) << " " << file_data.owner_dialog_id_ << " " << tag("size", file_data.size_) + << tag("expected_size", file_data.expected_size_); + if (!file_data.url_.empty()) { + sb << tag("url", file_data.url_); + } if (file_data.local_.type() == LocalFileLocation::Type::Full) { sb << " local " << file_data.local_.full(); } + if (file_data.generate_.type() == GenerateFileLocation::Type::Full) { + sb << " generate " << file_data.generate_.full(); + } if (file_data.remote_.type() == RemoteFileLocation::Type::Full) { sb << " remote " << file_data.remote_.full(); } diff --git a/td/telegram/files/FileStatsWorker.cpp b/td/telegram/files/FileStatsWorker.cpp index d45a8d6b..999402ae 100644 --- a/td/telegram/files/FileStatsWorker.cpp +++ b/td/telegram/files/FileStatsWorker.cpp @@ -50,7 +50,7 @@ Status scan_db(CallbackT &&callback) { FileData data; auto status = unserialize(data, value); if (status.is_error()) { - LOG(ERROR) << "Invalid FileData in db " << tag("value", format::escaped(value)); + LOG(ERROR) << "Invalid FileData in the database " << tag("value", format::escaped(value)); return; } DbFileInfo info; @@ -67,10 +67,11 @@ Status scan_db(CallbackT &&callback) { if (path_view.is_relative()) { info.path = get_files_base_dir(info.file_type) + info.path; } + // LOG(INFO) << "Found file in the database: " << data << " " << info.path; info.owner_dialog_id = data.owner_dialog_id_; info.size = data.size_; if (info.size == 0 && data.local_.type() == LocalFileLocation::Type::Full) { - LOG(ERROR) << "Unknown size in db"; + LOG(ERROR) << "Unknown size in the database"; return; } callback(info); @@ -147,7 +148,10 @@ void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_ info.size = fs_info.size; info.atime_nsec = fs_info.atime_nsec; info.mtime_nsec = fs_info.mtime_nsec; - full_infos.push_back(info); + + // LOG(INFO) << "Found file of size " << info.size << " at " << info.path; + + full_infos.push_back(std::move(info)); }); std::unordered_map hash_to_pos; @@ -161,6 +165,7 @@ void FileStatsWorker::get_stats(bool need_all_files, bool split_by_owner_dialog_ if (it == hash_to_pos.end()) { return; } + // LOG(INFO) << "Match! " << db_info.path << " from " << db_info.owner_dialog_id; full_infos[it->second].owner_dialog_id = db_info.owner_dialog_id; }); diff --git a/tdutils/td/utils/port/path.h b/tdutils/td/utils/port/path.h index 00c36888..8f145d78 100644 --- a/tdutils/td/utils/port/path.h +++ b/tdutils/td/utils/port/path.h @@ -212,7 +212,11 @@ Status walk_path_dir(const std::wstring &dir_name, Func &&func) { template Status walk_path(CSlice path, Func &&func) { - TRY_RESULT(wpath, to_wstring(path)); + Slice path_slice = path; + while (!path_slice.empty() && (path_slice.back() == '/' || path_slice.back() == '\\')) { + path_slice.remove_suffix(1); + } + TRY_RESULT(wpath, to_wstring(path_slice)); return detail::walk_path_dir(wpath.c_str(), func); }