fix weird end-of-file bug by having downloaders use inotify to directly track changes
This commit is contained in:
parent
ba4c7bfcbe
commit
cc0aaaab94
8 changed files with 246 additions and 283 deletions
|
@ -1,5 +1,4 @@
|
|||
mod download;
|
||||
mod file;
|
||||
mod state;
|
||||
mod upload;
|
||||
mod util;
|
||||
|
@ -7,7 +6,6 @@ mod zip;
|
|||
|
||||
use std::{fs::File, path::PathBuf};
|
||||
|
||||
use actix::Addr;
|
||||
use actix_web::{
|
||||
get, middleware::Logger, web, App, HttpRequest, HttpResponse, HttpServer, Responder,
|
||||
};
|
||||
|
@ -41,8 +39,6 @@ pub struct DownloadableFile {
|
|||
size: u64,
|
||||
#[serde(with = "state::timestamp")]
|
||||
modtime: OffsetDateTime,
|
||||
#[serde(skip)]
|
||||
uploader: Option<Addr<upload::Uploader>>,
|
||||
}
|
||||
|
||||
type AppData = web::Data<RwLock<PersistentState>>;
|
||||
|
@ -64,8 +60,11 @@ async fn handle_download(
|
|||
let data = data.read().await;
|
||||
let info = data.lookup_file(&file_code);
|
||||
if let Some(info) = info {
|
||||
let storage_path = storage_dir().join(file_code);
|
||||
let file = File::open(&storage_path)?;
|
||||
Ok(download::DownloadingFile {
|
||||
file: File::open(storage_dir().join(file_code))?,
|
||||
file,
|
||||
storage_path,
|
||||
info,
|
||||
}
|
||||
.into_response(&req))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue