mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
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.
This commit is contained in:
parent
4fdf562fba
commit
2379f5bce0
1 changed files with 6 additions and 2 deletions
|
|
@ -31,7 +31,9 @@ fn write_with_retry(path: &Path, contents: &[u8]) -> io::Result<()> {
|
||||||
Ok(()) => return Ok(()),
|
Ok(()) => return Ok(()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Only retry on "Access denied" (os error 5) or "Sharing violation" (os error 32)
|
// 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 {
|
if should_retry && attempt < MAX_RETRIES {
|
||||||
log::trace!(
|
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) if err.kind() == io::ErrorKind::NotFound => return Ok(()),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Only retry on "Access denied" (os error 5) or "Sharing violation" (os error 32)
|
// 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 {
|
if should_retry && attempt < MAX_RETRIES {
|
||||||
log::trace!(
|
log::trace!(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue