Fix registering file sources in FileStatsWorker.

GitOrigin-RevId: 0a971c9248d5d4fa9106d7ef4751d2431a50c80e
This commit is contained in:
levlam 2019-03-18 00:40:10 +03:00
parent b5407cd6bc
commit 8cbbe017bd
4 changed files with 11 additions and 7 deletions

View File

@ -35,7 +35,7 @@ class FileData {
void store(StorerT &storer) const; void store(StorerT &storer) const;
template <class ParserT> template <class ParserT>
void parse(ParserT &parser); void parse(ParserT &parser, bool register_file_sources);
}; };
inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) { inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) {

View File

@ -61,7 +61,7 @@ void FileData::store(StorerT &storer) const {
} }
} }
template <class ParserT> template <class ParserT>
void FileData::parse(ParserT &parser) { void FileData::parse(ParserT &parser, bool register_file_sources) {
using ::td::parse; using ::td::parse;
bool has_owner_dialog_id; bool has_owner_dialog_id;
bool has_expected_size; bool has_expected_size;
@ -96,8 +96,8 @@ void FileData::parse(ParserT &parser) {
parse(url_, parser); parse(url_, parser);
encryption_key_.parse(encryption_key_is_secure ? FileEncryptionKey::Type::Secure : FileEncryptionKey::Type::Secret, encryption_key_.parse(encryption_key_is_secure ? FileEncryptionKey::Type::Secure : FileEncryptionKey::Type::Secret,
parser); parser);
if (has_sources) { if (has_sources && register_file_sources) {
auto td = G()->td().get_actor_unsafe(); Td *td = G()->td().get_actor_unsafe();
int32 size; int32 size;
parse(size, parser); parse(size, parser);
if (0 < size && size < 5) { if (0 < size && size < 5) {

View File

@ -275,8 +275,11 @@ class FileDb : public FileDbInterface {
//LOG(DEBUG) << "By id " << id.get() << " found data " << format::as_hex_dump<4>(Slice(data_str)); //LOG(DEBUG) << "By id " << id.get() << " found data " << format::as_hex_dump<4>(Slice(data_str));
//LOG(INFO) << attempt_count; //LOG(INFO) << attempt_count;
TlParser parser(data_str);
FileData data; FileData data;
auto status = unserialize(data, data_str); data.parse(parser, true);
parser.fetch_end();
auto status = parser.get_status();
if (status.is_error()) { if (status.is_error()) {
return std::move(status); return std::move(status);
} }

View File

@ -53,9 +53,10 @@ Status scan_db(CallbackT &&callback) {
if (value.substr(0, 2) == "@@") { if (value.substr(0, 2) == "@@") {
return; return;
} }
TlParser parser(value);
FileData data; FileData data;
auto status = unserialize(data, value); data.parse(parser, false);
if (status.is_error()) { if (parser.get_status().is_error()) {
LOG(ERROR) << "Invalid FileData in the database " << tag("value", format::escaped(value)); LOG(ERROR) << "Invalid FileData in the database " << tag("value", format::escaped(value));
return; return;
} }