Save video under batch counting date; fix retention timezone
This commit is contained in:
1 parent
a94c3dff87
commit
37f98f243c
9 files changed
+37
-19
No files matched your search
@@ -41,7 +41,7 @@ void VideoBatchWriter::cleanup_retention() {
|
||||
auto cutoff = std::chrono::system_clock::now() - std::chrono::hours(retention_days_ * 24);
|
||||
auto cutoff_t = std::chrono::system_clock::to_time_t(cutoff);
|
||||
std::ostringstream cutoff_ss;
|
||||
cutoff_ss << std::put_time(std::gmtime(&cutoff_t), "%Y-%m-%d");
|
||||
cutoff_ss << std::put_time(std::localtime(&cutoff_t), "%Y-%m-%d");
|
||||
std::string cutoff_str = cutoff_ss.str();
|
||||
|
||||
for (const auto& entry : fs::directory_iterator(output_dir_)) {
|
||||
@@ -86,8 +86,9 @@ void VideoBatchWriter::note_ayam_detection() {
|
||||
}
|
||||
}
|
||||
|
||||
void VideoBatchWriter::on_batch_closed(int batch_number) {
|
||||
void VideoBatchWriter::on_batch_closed(int batch_number, const std::string& counting_date) {
|
||||
current_batch_ = batch_number;
|
||||
current_date_ = counting_date;
|
||||
if (state_ == CONFIRMED) {
|
||||
state_ = STOPPING;
|
||||
state_start_ = std::chrono::steady_clock::now();
|
||||
@@ -175,7 +176,7 @@ void VideoBatchWriter::stop_and_move(int batch_number) {
|
||||
std::string src = current_path_;
|
||||
current_path_.clear();
|
||||
|
||||
std::string day_dir = output_dir_ + "/" + today_str();
|
||||
std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_);
|
||||
ensure_dir(day_dir);
|
||||
|
||||
std::ostringstream name;
|
||||
@@ -205,7 +206,7 @@ void VideoBatchWriter::shutdown() {
|
||||
current_path_.clear();
|
||||
|
||||
if (prev_state == CONFIRMED || prev_state == STOPPING) {
|
||||
std::string day_dir = output_dir_ + "/" + today_str();
|
||||
std::string day_dir = output_dir_ + "/" + (current_date_.empty() ? today_str() : current_date_);
|
||||
ensure_dir(day_dir);
|
||||
std::string dst = day_dir + "/" +
|
||||
fs::path(src).filename().string();
|
||||
|
||||
Reference in new issue
Block a user