From 69f0c098e3b3e01e033dddf789539a5dc74a3cf1 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 3 Dec 2017 16:58:31 -0800 Subject: [PATCH] check show_index --- src/fs.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 86b9ed55b..84da53c28 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -205,7 +205,7 @@ impl FromRequest for FilesystemElement { pub struct StaticFiles { directory: PathBuf, accessible: bool, - _show_index: bool, + show_index: bool, _chunk_size: usize, _follow_symlinks: bool, } @@ -237,7 +237,7 @@ impl StaticFiles { StaticFiles { directory: dir, accessible: access, - _show_index: index, + show_index: index, _chunk_size: 0, _follow_symlinks: false, } @@ -259,7 +259,11 @@ impl Handler for StaticFiles { let path = self.directory.join(&relpath).canonicalize()?; if path.is_dir() { - Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path))) + if self.show_index { + Ok(FilesystemElement::Directory(Directory::new(self.directory.clone(), path))) + } else { + Err(io::Error::new(io::ErrorKind::NotFound, "not found")) + } } else { Ok(FilesystemElement::File(NamedFile::open(path)?)) }