mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +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 {
|
if is_git_repo {
|
||||||
log::info!("Refreshing git index...");
|
log::info!("Refreshing git index...");
|
||||||
let result = Command::new("git")
|
let mut attempts = 0;
|
||||||
.args(["update-index", "--refresh"])
|
loop {
|
||||||
.current_dir(project_dir)
|
attempts += 1;
|
||||||
.stdout(Stdio::null())
|
let result = Command::new("git")
|
||||||
.stderr(Stdio::null())
|
.args(["update-index", "--refresh"])
|
||||||
.status();
|
.current_dir(project_dir)
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.status();
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
if status.success() {
|
if status.success() {
|
||||||
log::info!("Git index refreshed.");
|
log::info!("Git index refreshed.");
|
||||||
} else {
|
break;
|
||||||
log::warn!("git update-index --refresh exited with: {}", status);
|
} 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 {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue