send: fail fast when a retried local media file is gone

A retried ugoira/bsky temp MP4 was already deleted with its TempDir, so
the retry failed at multipart-build time with a confusing Io error and
wasted all three attempts. input_file_for now rejects a missing local
path up front as a clean permanent error.
This commit is contained in:
2026-08-08 20:10:35 +08:00
parent 98c48b99c0
commit b3d87b4f7d
+5
View File
@@ -329,6 +329,11 @@ fn item_url(item: &MediaItemPayload) -> &str {
fn input_file_for(media: &str) -> Result<InputFile, String> { fn input_file_for(media: &str) -> Result<InputFile, String> {
if media.starts_with("http://") || media.starts_with("https://") { if media.starts_with("http://") || media.starts_with("https://") {
Ok(InputFile::url(parse_media_url(media)?)) Ok(InputFile::url(parse_media_url(media)?))
} else if !std::path::Path::new(media).exists() {
// A retried task may reference a temp file the original send's
// TempDir already cleaned up; fail fast and permanent instead of
// burning retries on a file that can never come back.
Err(format!("local media file missing: {media}"))
} else { } else {
Ok(InputFile::file(media)) Ok(InputFile::file(media))
} }