This commit is contained in:
thek4n 2026-02-21 10:47:00 +03:00
parent f800d63e02
commit 91711c9e07
2 changed files with 43 additions and 7 deletions

37
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
# - id: no-commit-to-branch
# args: [--branch, master, --branch, main, --pattern, release/.*]
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: mixed-line-ending
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-executables-have-shebangs
- repo: local
hooks:
- id: clippy
name: clippy
language: system
entry: cargo clippy
pass_filenames: false
always_run: true
- id: cargo-fmt
name: cargo fmt
language: system
entry: cargo fmt
pass_filenames: false
always_run: true
- id: check-todos # [NOGREP]
name: check-todos # [NOGREP]
language: system
entry: sh -c "! grep --color=always --binary-files=without-match --dereference-recursive --exclude-dir='notes' --exclude-dir='node_modules' --exclude-dir='.git' --exclude='.pre-commit-config.yaml' --exclude-dir='venv' 'TODO'" # [NOGREP]
pass_filenames: false
always_run: true

View File

@ -7,7 +7,6 @@ use axum::{
};
use futures::StreamExt;
use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
use pulldown_cmark;
use pulldown_cmark::{CodeBlockKind, Event, Options, Tag, html};
use std::convert::Infallible;
use std::net::{SocketAddr, ToSocketAddrs};
@ -114,7 +113,7 @@ fn resolve_addr(host: &str, port: u16) -> io::Result<SocketAddr> {
}
async fn root(State(state): State<AppState>) -> Result<Html<String>, StatusCode> {
render_directory_index(&PathBuf::from(state.root), "").await
render_directory_index(&state.root, "").await
}
async fn sse_handler(
@ -342,13 +341,13 @@ async fn run_file_watcher(state: AppState) {
let tx_fs_clone = tx_fs.clone();
let mut watcher = RecommendedWatcher::new(
move |res: Result<notify::Event, notify::Error>| {
if let Ok(event) = res {
if matches!(event.kind, EventKind::Modify(_)) {
if let Ok(event) = res
&& matches!(event.kind, EventKind::Modify(_))
{
for path in event.paths {
let _ = tx_fs_clone.blocking_send(path);
}
}
}
},
Config::default(),
)