2018-12-31 20:04:05 +01:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/files/FileGcParameters.h"
|
|
|
|
|
|
|
|
#include "td/telegram/Global.h"
|
|
|
|
|
2018-11-15 22:25:08 +01:00
|
|
|
#include "td/utils/format.h"
|
2020-09-24 23:46:16 +02:00
|
|
|
#include "td/utils/misc.h"
|
2018-11-15 22:25:08 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
namespace td {
|
2018-11-15 22:25:08 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
FileGcParameters::FileGcParameters(int64 size, int32 ttl, int32 count, int32 immunity_delay,
|
|
|
|
vector<FileType> file_types, vector<DialogId> owner_dialog_ids,
|
|
|
|
vector<DialogId> exclude_owner_dialog_ids, int32 dialog_limit)
|
2021-12-11 21:03:11 +01:00
|
|
|
: file_types_(std::move(file_types))
|
|
|
|
, owner_dialog_ids_(std::move(owner_dialog_ids))
|
|
|
|
, exclude_owner_dialog_ids_(std::move(exclude_owner_dialog_ids))
|
|
|
|
, dialog_limit_(dialog_limit) {
|
2022-08-17 15:11:13 +02:00
|
|
|
max_files_size_ = size >= 0 ? size : G()->get_option_integer("storage_max_files_size", 100 << 10) << 10;
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-12-11 21:03:11 +01:00
|
|
|
max_time_from_last_access_ =
|
2022-08-17 15:11:13 +02:00
|
|
|
ttl >= 0 ? ttl : narrow_cast<int32>(G()->get_option_integer("storage_max_time_from_last_access", 60 * 60 * 23));
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2022-08-17 15:11:13 +02:00
|
|
|
max_file_count_ = count >= 0 ? count : narrow_cast<int32>(G()->get_option_integer("storage_max_file_count", 40000));
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2021-12-11 21:03:11 +01:00
|
|
|
immunity_delay_ = immunity_delay >= 0
|
|
|
|
? immunity_delay
|
2022-08-17 15:11:13 +02:00
|
|
|
: narrow_cast<int32>(G()->get_option_integer("storage_immunity_delay", 60 * 60));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
2018-11-15 22:25:08 +01:00
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const FileGcParameters ¶meters) {
|
2021-12-11 21:03:11 +01:00
|
|
|
return string_builder << "FileGcParameters[" << tag("max_files_size", parameters.max_files_size_)
|
|
|
|
<< tag("max_time_from_last_access", parameters.max_time_from_last_access_)
|
|
|
|
<< tag("max_file_count", parameters.max_file_count_)
|
|
|
|
<< tag("immunity_delay", parameters.immunity_delay_)
|
|
|
|
<< tag("file_types", parameters.file_types_)
|
|
|
|
<< tag("owner_dialog_ids", parameters.owner_dialog_ids_)
|
|
|
|
<< tag("exclude_owner_dialog_ids", parameters.exclude_owner_dialog_ids_)
|
|
|
|
<< tag("dialog_limit", parameters.dialog_limit_) << ']';
|
2018-11-15 22:25:08 +01:00
|
|
|
}
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|