From 2379f5bce0e60ae001e760ba4528e2a6fb9f4d24 Mon Sep 17 00:00:00 2001 From: Joe Date: Mon, 2 Feb 2026 18:11:28 -0600 Subject: [PATCH] Refactor error handling in retry logic for file operations - Improved readability of the retry logic in `write_with_retry` and `remove_file_with_retry` functions by formatting the condition for determining whether to retry on specific OS errors. This change enhances code clarity while maintaining existing functionality. --- src/syncback/fs_snapshot.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/syncback/fs_snapshot.rs b/src/syncback/fs_snapshot.rs index 619c968f..5718473f 100644 --- a/src/syncback/fs_snapshot.rs +++ b/src/syncback/fs_snapshot.rs @@ -31,7 +31,9 @@ fn write_with_retry(path: &Path, contents: &[u8]) -> io::Result<()> { Ok(()) => return Ok(()), Err(err) => { // Only retry on "Access denied" (os error 5) or "Sharing violation" (os error 32) - let should_retry = err.raw_os_error().is_some_and(|code| code == 5 || code == 32); + let should_retry = err + .raw_os_error() + .is_some_and(|code| code == 5 || code == 32); if should_retry && attempt < MAX_RETRIES { log::trace!( @@ -71,7 +73,9 @@ fn remove_file_with_retry(path: &Path) -> io::Result<()> { Err(err) if err.kind() == io::ErrorKind::NotFound => return Ok(()), Err(err) => { // Only retry on "Access denied" (os error 5) or "Sharing violation" (os error 32) - let should_retry = err.raw_os_error().is_some_and(|code| code == 5 || code == 32); + let should_retry = err + .raw_os_error() + .is_some_and(|code| code == 5 || code == 32); if should_retry && attempt < MAX_RETRIES { log::trace!(