Skip to content

Commit

Permalink
wacker: delete the log file when deleting a module
Browse files Browse the repository at this point in the history
  • Loading branch information
iawia002 committed Nov 22, 2023
1 parent 05bff89 commit 3e2a3b7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion wacker/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::{bail, Error, Result};
use log::{error, info, warn};
use rand::Rng;
use std::collections::HashMap;
use std::fs::{create_dir, OpenOptions};
use std::fs::{create_dir, remove_file, OpenOptions};
use std::io::{ErrorKind, Write};
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
Expand Down Expand Up @@ -204,6 +204,15 @@ impl wacker_api::modules_server::Modules for Service {
let req = request.into_inner();
info!("Delete the module: {}", req.id);

if let Err(err) = remove_file(self.home_dir.join(".wacker/logs").join(req.id.clone())) {
if err.kind() != ErrorKind::NotFound {
return Err(Status::internal(format!(
"failed to remove the log file for {}: {}",
req.id, err
)));
}
}

self.stop_and_remove(&req.id);
Ok(Response::new(()))
}
Expand Down

0 comments on commit 3e2a3b7

Please sign in to comment.