Skip to content

Commit

Permalink
Change file length max to constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Sep 30, 2024
1 parent b11711b commit 0ce1ff0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions deepwell/src/services/file_revision/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use crate::web::{Bytes, FetchDirection};
use once_cell::sync::Lazy;
use std::num::NonZeroI32;

pub const MAXIMUM_FILE_NAME_LENGTH: usize = 256;

/// The changes for the first revision.
/// The first revision is always considered to have changed everything.
///
Expand Down Expand Up @@ -131,8 +133,12 @@ impl FileRevisionService {
return Err(Error::FileNameEmpty);
}

if name.len() >= 256 {
error!("File name of invalid length: {}", name.len());
if name.len() >= MAXIMUM_FILE_NAME_LENGTH {
error!(
"File name of invalid length: {} > {}",
name.len(),
MAXIMUM_FILE_NAME_LENGTH,
);
return Err(Error::FileNameTooLong);
}

Expand Down

0 comments on commit 0ce1ff0

Please sign in to comment.