mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
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:
@@ -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))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user