diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-20 21:34:29 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-20 21:34:29 +0200 |
commit | f4042f7ea50995353550f5823f3ebdb6fb1e3cc5 (patch) | |
tree | cb66f3c22fcaf77a1842ccaa07c1e1662ec43ece | |
parent | 56be838f546b8ec8de0c90f79adfffc6b341e746 (diff) | |
download | gnix-f4042f7ea50995353550f5823f3ebdb6fb1e3cc5.tar gnix-f4042f7ea50995353550f5823f3ebdb6fb1e3cc5.tar.bz2 gnix-f4042f7ea50995353550f5823f3ebdb6fb1e3cc5.tar.zst |
files: sort file listing
-rw-r--r-- | src/modules/files.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/modules/files.rs b/src/modules/files.rs index a37098d..7d6665a 100644 --- a/src/modules/files.rs +++ b/src/modules/files.rs @@ -337,11 +337,14 @@ fn reserve_at_least(buf: &mut BytesMut, cap: usize) { } async fn index(path: &Path, rpath: String) -> Result<String, ServiceError> { - let files = path + let mut files = path .read_dir()? .map(|e| e.and_then(|e| Ok((e.file_name().into_string().unwrap(), e.metadata()?)))) .filter(|e| e.as_ref().map(|(e, _)| !e.starts_with(".")).unwrap_or(true)) .collect::<Result<Vec<_>, _>>()?; + + files.sort_by(|a, b| a.0.cmp(&b.0)); + let banner = read_to_string(path.join("index.banner.html")).await.ok(); let s = IndexTemplate { files, |