From 0ce1ff02e119b6371bf3d23647bbca20727134ab Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 30 Sep 2024 01:36:32 -0400 Subject: [PATCH] Change file length max to constant. --- deepwell/src/services/file_revision/service.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deepwell/src/services/file_revision/service.rs b/deepwell/src/services/file_revision/service.rs index f58eccd4a73..17b1697f6d5 100644 --- a/deepwell/src/services/file_revision/service.rs +++ b/deepwell/src/services/file_revision/service.rs @@ -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. /// @@ -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); }