fix: panic when unable to delete files
This commit is contained in:
parent
6e5892a209
commit
aef400ff51
|
@ -46,8 +46,11 @@ pub(crate) async fn delete_by_id(
|
|||
|
||||
async fn delete_content(file_id: &str, files_dir: &Path) -> Result<(), std::io::Error> {
|
||||
let path = files_dir.join(file_id);
|
||||
if fs::remove_file(&path).await.is_ok() {
|
||||
log::info!("delete file {}", file_id);
|
||||
if fs::try_exists(&path).await? {
|
||||
fs::remove_file(&path).await?;
|
||||
log::info!("deleted file {}", file_id);
|
||||
} else {
|
||||
log::warn!("expiring file {} was missing from the filesystem", file_id);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -58,7 +61,7 @@ async fn wait_for_file_expiry(receiver: &mut Receiver<()>, db: &PgPool) {
|
|||
.fetch_one(db)
|
||||
.await
|
||||
.expect("could not fetch expiring files from database");
|
||||
let next_timeout: std::time::Duration = match valid_till.0 {
|
||||
let next_timeout = match valid_till.0 {
|
||||
Some(valid_till) => (max(
|
||||
0,
|
||||
valid_till.unix_timestamp() - OffsetDateTime::now_utc().unix_timestamp(),
|
||||
|
|
Loading…
Reference in New Issue