Commit 50862fc5 authored by Johannes Barthel's avatar Johannes Barthel
Browse files

include activity-report directory in cleanup (if present)

parent 53be2546
Pipeline #5975 passed with stages
in 6 minutes and 57 seconds
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "0.7.15"
......@@ -53,7 +55,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cleanup-meeting-data"
version = "0.2.3"
version = "0.2.4"
dependencies = [
"lazy_static",
"regex",
......
[package]
name = "cleanup-meeting-data"
version = "0.2.3"
version = "0.2.4"
authors = ["Johannes <johannes@senfcall.de>"]
edition = "2018"
......
use serde::Deserialize;
use std::collections::HashSet;
use std::fs;
use std::path::Path;
lazy_static::lazy_static! {
static ref DEBUG: bool = {
......@@ -53,9 +54,9 @@ struct MongoNote {
note_id: String,
}
fn get_meetings_on_disk() -> HashSet<String> {
fn get_meetings_in_directory(dir : &str) -> HashSet<String> {
let re = regex::Regex::new(r"^[0-9a-f]{40}-\d+$").unwrap();
fs::read_dir("/var/bigbluebutton/")
fs::read_dir(dir)
.unwrap()
.filter_map(|e| {
let as_string = e.unwrap().file_name().to_str().unwrap().to_owned();
......@@ -68,6 +69,18 @@ fn get_meetings_on_disk() -> HashSet<String> {
.collect()
}
fn get_meetings_on_disk() -> HashSet<String> {
get_meetings_in_directory("/var/bigbluebutton/")
}
fn get_activity_reports() -> HashSet<String> {
if Path::new("/var/bigbluebutton/activity-report/").is_dir() {
get_meetings_in_directory("/var/bigbluebutton/activity-report/")
} else {
HashSet::new()
}
}
fn get_stored_notes(etherpad_api_version: &str, etherpad_api_key: &str) -> Vec<String> {
let api_call = format!(
"http://localhost:9001/api/{}/listAllPads?apikey={}",
......@@ -158,6 +171,9 @@ fn main() {
let meetings_on_disk: HashSet<String> = get_meetings_on_disk();
println!("found {} meetings on disk.", meetings_on_disk.len());
let activity_reports : HashSet<String> = get_activity_reports();
println!("found {} activity reports on disk.", activity_reports.len());
let stored_notes = get_stored_notes(&etherpad_api_version, &etherpad_api_key);
let all_note_pads_by_meeting_id = get_mongo_notes_by_meeting_id();
......@@ -225,19 +241,24 @@ fn main() {
}
}
let stale_meetings: Vec<String> = meetings_on_disk
.difference(&running_meetings)
.map(|x| format!("/var/bigbluebutton/{}", x))
.collect();
fn remove_stale(base_dir : &str, present : &HashSet<String>, running : &HashSet<String>) {
let stale_meetings: Vec<String> = present
.difference(running)
.map(|x| format!("{}/{}", base_dir, x))
.collect();
println!("found {} stale meetings on disk.", stale_meetings.len());
println!("found {} stale meetings in {}.", stale_meetings.len(), base_dir);
for dirname in stale_meetings {
print!("deleting {}...", dirname);
std::fs::remove_dir_all(dirname).unwrap();
println!(" removed!");
for dirname in stale_meetings {
print!("deleting {}...", dirname);
std::fs::remove_dir_all(dirname).unwrap();
println!(" removed!");
}
}
remove_stale("/var/bigbluebutton", &meetings_on_disk, &running_meetings);
remove_stale("/var/bigbluebutton/activity-report", &activity_reports, &running_meetings);
if *DEBUG {
dbg!(&kept_notes);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment