From a0ba8e7ea8a09be4a2eeb66606bb3653efadf530 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Sun, 1 Jun 2025 18:01:21 -0500 Subject: [PATCH] Use pre Rust 1.81 compatible file-exists test The function `std::fs::exists(...)` was stabilized in Rust 1.81, which means it can't be used in the Debian Bookworm build. This patch swaps to a compatible implementation leaning on the std::path::Path struct. I'm both "upstreaming" a Debian-specific patch I had to make for the package, and fixing the additional usage now in `main.rs`. There doesn't seem to be any compelling reason to avoid using this function, so I figure I should merge it into the base release. --- src/api/release_attachment.rs | 5 +++-- src/main.rs | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/api/release_attachment.rs b/src/api/release_attachment.rs index d4fda6f..ae626ef 100644 --- a/src/api/release_attachment.rs +++ b/src/api/release_attachment.rs @@ -1,4 +1,4 @@ -use std::fs; +use std::{fs, path}; use crate::structs::Attachment; @@ -16,7 +16,8 @@ pub async fn create_release_attachment( ) -> crate::Result { let request_url = format!("{gitea_url}/api/v1/repos/{repo}/releases/{release_id}/assets"); - match fs::exists(&file) { + let path = path::Path::new(&file); + match path.try_exists() { Ok(true) => (), Ok(false) => return Err(crate::Error::NoSuchFile), Err(e) => { diff --git a/src/main.rs b/src/main.rs index 650be33..555b843 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ -use std::fs; + +use std::path; use gt_tool::cli::Args; use gt_tool::structs::release::{CreateReleaseOption, Release}; @@ -81,7 +82,8 @@ async fn main() -> Result<(), gt_tool::Error> { if let Some(release) = match_release_by_tag(&tag_name, release_candidates) { for file in &files { - match fs::exists(file) { + let path = path::Path::new(&file); + match path.try_exists() { Ok(true) => continue, Ok(false) => return Err(gt_tool::Error::NoSuchFile), Err(e) => {