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;
template <class ParserT>
void parse(ParserT &parser);
void parse(ParserT &parser, bool register_file_sources);
};
inline StringBuilder &operator<<(StringBuilder &sb, const FileData &file_data) {

View File

@ -61,7 +61,7 @@ void FileData::store(StorerT &storer) const {
}
}
template <class ParserT>
void FileData::parse(ParserT &parser) {
void FileData::parse(ParserT &parser, bool register_file_sources) {
using ::td::parse;
bool has_owner_dialog_id;
bool has_expected_size;
@ -96,8 +96,8 @@ void FileData::parse(ParserT &parser) {
parse(url_, parser);
encryption_key_.parse(encryption_key_is_secure ? FileEncryptionKey::Type::Secure : FileEncryptionKey::Type::Secret,
parser);
if (has_sources) {
auto td = G()->td().get_actor_unsafe();
if (has_sources && register_file_sources) {
Td *td = G()->td().get_actor_unsafe();
int32 size;
parse(size, parser);
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(INFO) << attempt_count;
TlParser parser(data_str);
FileData data;
auto status = unserialize(data, data_str);
data.parse(parser, true);
parser.fetch_end();
auto status = parser.get_status();
if (status.is_error()) {
return std::move(status);
}

View File

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