Skip to content

Commit 9801932

Browse files
Refactor: Make GitHelpers.FetchOrigin async
1 parent bd84f34 commit 9801932

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/Files.App/Actions/Git/GitFetchAction.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public GitFetchAction()
2525

2626
public Task ExecuteAsync(object? parameter = null)
2727
{
28-
GitHelpers.FetchOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath);
29-
30-
return Task.CompletedTask;
28+
return GitHelpers.FetchOrigin(_context.ShellPage!.InstanceViewModel.GitRepositoryPath);
3129
}
3230

3331
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)

src/Files.App/Utils/Git/GitHelpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ public static bool ValidateBranchNameForRepository(string branchName, string rep
334334
branch.FriendlyName.Equals(branchName, StringComparison.OrdinalIgnoreCase));
335335
}
336336

337-
public static async void FetchOrigin(string? repositoryPath, CancellationToken cancellationToken = default)
337+
public static async Task FetchOrigin(string? repositoryPath, CancellationToken cancellationToken = default)
338338
{
339339
if (string.IsNullOrWhiteSpace(repositoryPath))
340340
return;

src/Files.App/Views/Shells/BaseShellPage.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ protected async void FilesystemViewModel_DirectoryInfoUpdated(object sender, Eve
247247
}
248248
if (InstanceViewModel.IsGitRepository && (!GitHelpers.IsExecutingGitAction || isGitFetchCanceled))
249249
{
250-
_gitFetch = Task.Run(
251-
() => GitHelpers.FetchOrigin(InstanceViewModel.GitRepositoryPath, _gitFetchToken.Token),
252-
_gitFetchToken.Token);
250+
_gitFetch = GitHelpers.FetchOrigin(InstanceViewModel.GitRepositoryPath, _gitFetchToken.Token);
253251
}
254252
}
255253

0 commit comments

Comments
 (0)