mirror of
https://github.com/YGGverse/titanit.git
synced 2026-03-31 09:05:45 +00:00
fix data write
This commit is contained in:
parent
d33c678e3f
commit
f62153ac91
1 changed files with 2 additions and 7 deletions
|
|
@ -72,7 +72,7 @@ fn handle(argument: Arc<Argument>, peer: SocketAddr, stream: &mut TlsStream<TcpS
|
|||
stream,
|
||||
|result| match result {
|
||||
Ok(()) => println!(
|
||||
"[{}] [error] [{peer}] Request: {}",
|
||||
"[{}] [info] [{peer}] Request: {}",
|
||||
now(),
|
||||
gemini.url
|
||||
),
|
||||
|
|
@ -105,10 +105,8 @@ fn handle(argument: Arc<Argument>, peer: SocketAddr, stream: &mut TlsStream<TcpS
|
|||
),
|
||||
Ok(l) => {
|
||||
data.extend(&input[..l]);
|
||||
|
||||
// calculate once
|
||||
let total = data.len();
|
||||
|
||||
// validate server-side limits
|
||||
if argument.size.is_some_and(|limit| total > limit) {
|
||||
const MESSAGE: &str =
|
||||
|
|
@ -130,7 +128,6 @@ fn handle(argument: Arc<Argument>, peer: SocketAddr, stream: &mut TlsStream<TcpS
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
// all expected data received
|
||||
if titan.size >= total {
|
||||
// validate client-side limits
|
||||
|
|
@ -157,12 +154,10 @@ fn handle(argument: Arc<Argument>, peer: SocketAddr, stream: &mut TlsStream<TcpS
|
|||
},
|
||||
);
|
||||
}
|
||||
|
||||
// @TODO detect/validate/cache mime based on data received
|
||||
|
||||
// success
|
||||
match storage::Item::create(&argument.directory) {
|
||||
Ok(mut tmp) => match tmp.file.write(titan.data) {
|
||||
Ok(mut tmp) => match tmp.file.write(&data) {
|
||||
Ok(_) => match tmp.commit() {
|
||||
Ok(pmt) => send(
|
||||
&response::redirect::Permanent {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue