aboutsummaryrefslogtreecommitdiff
path: root/src/jobs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/jobs.rs')
-rw-r--r--src/jobs.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/jobs.rs b/src/jobs.rs
index a01a70d..cac7660 100644
--- a/src/jobs.rs
+++ b/src/jobs.rs
@@ -18,19 +18,19 @@ pub async fn start(db_conn: Connection, files_dir: String) {
}
}
-async fn cleanup_expired(db_conn: &Connection, files_dir: &String) {
+async fn cleanup_expired(db_conn: &Connection, files_dir: &str) {
let time = Local::now();
match read_dir(files_dir).await {
Err(msg) => log::error!("Listing files: {msg}"),
- Ok(files) => match db::list_expire_after(db_conn, time).await {
+ Ok(files) => match db::files::list_expire_after(db_conn, time).await {
Err(msg) => log::error!("Getting non expirable files: {msg}"),
Ok(non_expirable) => {
let non_expirable = HashSet::<String>::from_iter(non_expirable.iter().cloned());
let expired_ids = files.difference(&non_expirable);
let count = remove_files(files_dir, expired_ids.cloned()).await;
log::info!("Removed {} files", count);
- if let Err(msg) = db::remove_expire_before(db_conn, time).await {
+ if let Err(msg) = db::files::remove_expire_before(db_conn, time).await {
log::error!("Removing files: {msg}")
}
}
@@ -38,7 +38,7 @@ async fn cleanup_expired(db_conn: &Connection, files_dir: &String) {
}
}
-async fn read_dir(files_dir: &String) -> Result<HashSet<String>, String> {
+async fn read_dir(files_dir: &str) -> Result<HashSet<String>, String> {
match fs::read_dir(files_dir).await {
Err(msg) => Err(msg.to_string()),
Ok(mut read_dir) => {
@@ -61,16 +61,16 @@ async fn read_dir(files_dir: &String) -> Result<HashSet<String>, String> {
}
}
-async fn remove_files<I>(files_dir: &String, ids: I) -> i32
+async fn remove_files<I>(files_dir: &str, ids: I) -> i32
where
I: Iterator<Item = String>,
{
let mut count = 0;
for id in ids {
- let path = Path::new(&files_dir).join(id.clone());
+ let path = Path::new(files_dir).join(id.clone());
match fs::remove_file(path).await {
Err(msg) => log::error!("Removing file: {msg}"),
- Ok(_) => count += 1
+ Ok(_) => count += 1,
}
}
count