@@ -9,8 +9,6 @@ namespace Files.App.ViewModels.Dialogs
99{
1010 public sealed partial class CloneRepoDialogViewModel : ObservableObject
1111 {
12- private readonly StatusCenterViewModel StatusCenterViewModel = Ioc . Default . GetRequiredService < StatusCenterViewModel > ( ) ;
13-
1412 public bool CanCloneRepo
1513 {
1614 get
@@ -45,11 +43,11 @@ public string RepoName
4543
4644 }
4745
48- private string workingDirectory ;
49- public string WorkingDirectory
46+ private string targetDirectory ;
47+ public string TargetDirectory
5048 {
51- get => workingDirectory ;
52- set => SetProperty ( ref workingDirectory , value ) ;
49+ get => targetDirectory ;
50+ set => SetProperty ( ref targetDirectory , value ) ;
5351
5452 }
5553
@@ -70,57 +68,14 @@ public CloneRepoDialogViewModel(string repoUrl, string workingDirectory)
7068 RepoName = string . Empty ;
7169 }
7270
73- WorkingDirectory = workingDirectory ;
71+ TargetDirectory = Path . Combine ( workingDirectory , RepoName ) ;
7472
7573 CloneRepoCommand = new AsyncRelayCommand ( DoCloneRepo ) ;
7674 }
7775
7876 private async Task DoCloneRepo ( )
7977 {
80- string targetDirectory = Path . Combine ( WorkingDirectory , RepoName ) ;
81- var banner = StatusCenterHelper . AddCard_GitClone ( RepoName . CreateEnumerable ( ) , targetDirectory . CreateEnumerable ( ) , ReturnResult . InProgress ) ;
82- var fsProgress = new StatusCenterItemProgressModel ( banner . ProgressEventSource , enumerationCompleted : true , FileSystemStatusCode . InProgress ) ;
83-
84- bool isSuccess = await Task . Run ( ( ) =>
85- {
86- try
87- {
88- var cloneOptions = new CloneOptions
89- {
90- FetchOptions =
91- {
92- OnTransferProgress = progress =>
93- {
94- banner . CancellationToken . ThrowIfCancellationRequested ( ) ;
95- fsProgress . ItemsCount = progress . TotalObjects ;
96- fsProgress . SetProcessedSize ( progress . ReceivedBytes ) ;
97- fsProgress . AddProcessedItemsCount ( 1 ) ;
98- fsProgress . Report ( ( int ) ( ( progress . ReceivedObjects / ( double ) progress . TotalObjects ) * 100 ) ) ;
99- return true ;
100- } ,
101- OnProgress = _ => ! banner . CancellationToken . IsCancellationRequested
102- } ,
103- OnCheckoutProgress = ( path , completed , total ) =>
104- banner . CancellationToken . ThrowIfCancellationRequested ( )
105- } ;
106-
107- Repository . Clone ( RepoUrl , targetDirectory , cloneOptions ) ;
108- return true ;
109- }
110- catch
111- {
112- return false ;
113- }
114- } , banner . CancellationToken ) ;
115-
116- StatusCenterViewModel . RemoveItem ( banner ) ;
117-
118- StatusCenterHelper . AddCard_GitClone (
119- RepoName . CreateEnumerable ( ) ,
120- targetDirectory . CreateEnumerable ( ) ,
121- isSuccess ? ReturnResult . Success :
122- banner . CancellationToken . IsCancellationRequested ? ReturnResult . Cancelled :
123- ReturnResult . Failed ) ;
78+ await GitHelpers . CloneRepoAsync ( RepoUrl , repoName , targetDirectory ) ;
12479 }
12580 }
12681}
0 commit comments