Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
senfcall-public
cleanup-meeting-data
Commits
50862fc5
Commit
50862fc5
authored
Aug 20, 2021
by
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
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
50862fc5
# 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",
...
...
Cargo.toml
View file @
50862fc5
[package]
name
=
"cleanup-meeting-data"
version
=
"0.2.
3
"
version
=
"0.2.
4
"
authors
=
[
"Johannes <johannes@senfcall.de>"
]
edition
=
"2018"
...
...
src/main.rs
View file @
50862fc5
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_
o
n_di
sk
(
)
->
HashSet
<
String
>
{
fn
get_meetings_
i
n_di
rectory
(
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
o
n
disk
."
,
stale_meetings
.len
());
println!
(
"found {} stale meetings
i
n
{}
."
,
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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment