Fix content range serving
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

This commit is contained in:
Aode (lion) 2022-03-26 20:46:34 -05:00
parent 356e57e53d
commit 32045d2bef
4 changed files with 7 additions and 3 deletions

2
Cargo.lock generated
View file

@ -1580,7 +1580,7 @@ dependencies = [
[[package]]
name = "pict-rs"
version = "0.3.0-rc.7"
version = "0.3.0-rc.8"
dependencies = [
"actix-form-data",
"actix-rt",

View file

@ -1,7 +1,7 @@
[package]
name = "pict-rs"
description = "A simple image hosting service"
version = "0.3.0-rc.7"
version = "0.3.0-rc.8"
authors = ["asonix <asonix@asonix.dog>"]
license = "AGPL-3.0"
readme = "README.md"

View file

@ -9,7 +9,7 @@ _a simple image hosting service_
## Usage
### Running
```
pict-rs 0.3.0-rc.7
pict-rs 0.3.0-rc.8
USAGE:
pict-rs [FLAGS] [OPTIONS] [SUBCOMMAND]

View file

@ -15,6 +15,8 @@ pub(crate) fn chop_bytes(
length: u64,
) -> Result<impl Stream<Item = Result<Bytes, Error>>, Error> {
if let Some((start, end)) = byte_range.to_satisfiable_range(length) {
// END IS INCLUSIVE
let end = end as usize + 1;
return Ok(once(ready(Ok(bytes.slice(start as usize..end as usize)))));
}
@ -31,6 +33,8 @@ where
Error: From<S::Error>,
{
if let Some((start, end)) = byte_range.to_satisfiable_range(length) {
// END IS INCLUSIVE
let end = end + 1;
return Ok(store
.to_stream(identifier, Some(start), Some(end.saturating_sub(start)))
.await?);