Skip to content

Commit

Permalink
refactor(paste): update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 11, 2024
1 parent 84305fb commit c4040f3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/paste.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ impl Paste {
if let Some(max_dir_size) = config.server.max_upload_dir_size {
let file_size = u64::try_from(self.data.len()).unwrap_or_default();
let upload_dir = self.type_.get_path(&config.server.upload_path)?;
let current_size_of_upload_dir = util::get_dir_size(&upload_dir)
.map_err(|_| error::ErrorInternalServerError("Internal server error occured"))?;
let current_size_of_upload_dir = util::get_dir_size(&upload_dir).map_err(|e| {
error::ErrorInternalServerError(format!("could not get directory size: {e}"))
})?;
let expected_size_of_upload_dir = current_size_of_upload_dir.add(file_size);
if expected_size_of_upload_dir > max_dir_size {
return Err(error::ErrorInsufficientStorage(
Expand Down

0 comments on commit c4040f3

Please sign in to comment.