Play and delete a torrent that came as a folder of files (#158)
A torrent of several files is recorded as its folder. /media could not serve a folder, and the reaper's remove_file failed on it, warned "could not delete" on every pass and freed nothing, so it counted against the quota for good; Delete in the page failed the same way. download::remove deletes a file or a whole folder, for the reaper and Delete alike, and the reaper counts a folder by its recorded size, as a directory's own size is not its contents'. download::playable answers the path itself, or for a folder the largest file in it, which is the episode, and /media serves that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1758,7 +1758,7 @@ async fn delete_file(
|
||||
}
|
||||
}
|
||||
if let Some(path) = &enc.path
|
||||
&& let Err(e) = std::fs::remove_file(path)
|
||||
&& let Err(e) = crate::download::remove(std::path::Path::new(path))
|
||||
&& e.kind() != std::io::ErrorKind::NotFound
|
||||
{
|
||||
return Err(e.into());
|
||||
@@ -1863,7 +1863,7 @@ async fn media(
|
||||
let Some(path) = enc.path else {
|
||||
return (StatusCode::NOT_FOUND, "not downloaded").into_response();
|
||||
};
|
||||
match ServeFile::new(path).oneshot(req).await {
|
||||
match ServeFile::new(crate::download::playable(std::path::Path::new(&path))).oneshot(req).await {
|
||||
Ok(r) => r.into_response(),
|
||||
Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user