mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Implement retry logic for git index refresh in syncback
- Enhanced the `refresh_git_index` function to include a retry mechanism for the `git update-index --refresh` command, allowing for up to two attempts with a 500ms delay between retries in case of failure. This improves robustness in handling transient errors during the refresh process.
This commit is contained in:
parent
d5522b2fef
commit
d4ae0820bc
1 changed files with 36 additions and 15 deletions
|
|
@ -361,23 +361,44 @@ fn refresh_git_index(project_dir: &Path) {
|
|||
|
||||
if is_git_repo {
|
||||
log::info!("Refreshing git index...");
|
||||
let result = Command::new("git")
|
||||
.args(["update-index", "--refresh"])
|
||||
.current_dir(project_dir)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status();
|
||||
let mut attempts = 0;
|
||||
loop {
|
||||
attempts += 1;
|
||||
let result = Command::new("git")
|
||||
.args(["update-index", "--refresh"])
|
||||
.current_dir(project_dir)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status();
|
||||
|
||||
match result {
|
||||
Ok(status) => {
|
||||
if status.success() {
|
||||
log::info!("Git index refreshed.");
|
||||
} else {
|
||||
log::warn!("git update-index --refresh exited with: {}", status);
|
||||
match result {
|
||||
Ok(status) => {
|
||||
if status.success() {
|
||||
log::info!("Git index refreshed.");
|
||||
break;
|
||||
} else if attempts < 2 {
|
||||
log::debug!(
|
||||
"git update-index --refresh exited with: {}, retrying in 500ms...",
|
||||
status
|
||||
);
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
} else {
|
||||
log::warn!("git update-index --refresh exited with: {}", status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
if attempts < 2 {
|
||||
log::debug!(
|
||||
"Failed to run git update-index --refresh: {}, retrying in 500ms...",
|
||||
e
|
||||
);
|
||||
std::thread::sleep(std::time::Duration::from_millis(500));
|
||||
} else {
|
||||
log::warn!("Failed to run git update-index --refresh: {}", e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("Failed to run git update-index --refresh: {}", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue