This commit is contained in:
@@ -63,21 +63,20 @@ pub async fn download(
|
||||
pub async fn serve_file(req: HttpRequest, file: &File, download_file: bool) -> HttpResult {
|
||||
if !download_file {
|
||||
// Check if the browser already knows the etag
|
||||
if let Some(c) = req.headers().get(header::IF_NONE_MATCH) {
|
||||
if c.to_str().unwrap_or("") == file.sha512.as_str() {
|
||||
return Ok(HttpResponse::NotModified().finish());
|
||||
}
|
||||
if let Some(c) = req.headers().get(header::IF_NONE_MATCH)
|
||||
&& c.to_str().unwrap_or("") == file.sha512.as_str()
|
||||
{
|
||||
return Ok(HttpResponse::NotModified().finish());
|
||||
}
|
||||
|
||||
// Check if the browser already knows the file by date
|
||||
if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
|
||||
let date_str = c.to_str().unwrap_or("");
|
||||
if let Ok(date) = httpdate::parse_http_date(date_str) {
|
||||
if date.add(Duration::from_secs(1))
|
||||
if let Ok(date) = httpdate::parse_http_date(date_str)
|
||||
&& date.add(Duration::from_secs(1))
|
||||
>= time_utils::unix_to_system_time(file.time_create as u64)
|
||||
{
|
||||
return Ok(HttpResponse::NotModified().finish());
|
||||
}
|
||||
{
|
||||
return Ok(HttpResponse::NotModified().finish());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ pub async fn get_list_of_account(
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(limit) = query.limit {
|
||||
if list.len() > limit {
|
||||
list = list[..limit].to_vec();
|
||||
}
|
||||
if let Some(limit) = query.limit
|
||||
&& list.len() > limit
|
||||
{
|
||||
list = list[..limit].to_vec();
|
||||
}
|
||||
|
||||
Ok(HttpResponse::Ok().json(list))
|
||||
|
||||
Reference in New Issue
Block a user