feat: Continue running if git fetch fails

As long as there's a valid clone available and no other git commands
fail, we allow `git fetch` to fail and proceed processing commands. Even
if internet connectivity is down, that shouldn't necessarily prevent
sync from functioning.

The primary motivation for this change is that we expect the Trash
Guides repo to be relocated soon and I do not want that to cause the
program to stop working between the change and when I can update the
URL.
pull/201/head
Robert Dailey 11 months ago
parent 012a9ef755
commit 11f3ab005b

@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
- Recyclarr will now continue if `git fetch` fails for any repos, so long as there is an existing,
valid clone to use.
## [5.0.0] - 2023-06-22
This release contains **BREAKING CHANGES**. See the [v5.0 Upgrade Guide][breaking5] for required

@ -51,7 +51,20 @@ public class RepoUpdater : IRepoUpdater
using var repo = await _repositoryFactory.CreateAndCloneIfNeeded(cloneUrl, repoPath, branch);
await repo.ForceCheckout(branch);
await repo.Fetch();
try
{
await repo.Fetch();
}
catch (GitCmdException e)
{
_log.Debug(e, "Non-zero exit code {ExitCode} while running git fetch: {Error}", e.ExitCode, e.Error);
_log.Error(
"Updating the repo '{RepoDir}' (git fetch) failed. Proceeding with existing files. " +
"Check clone URL is correct and that github is not down",
repoPath.Name);
}
await repo.ResetHard(repoSettings.Sha1 ?? $"origin/{branch}");
}
}

Loading…
Cancel
Save