@@ -9,8 +9,6 @@ namespace Files.App.ViewModels.Dialogs
9
9
{
10
10
public sealed partial class CloneRepoDialogViewModel : ObservableObject
11
11
{
12
- private readonly StatusCenterViewModel StatusCenterViewModel = Ioc . Default . GetRequiredService < StatusCenterViewModel > ( ) ;
13
-
14
12
public bool CanCloneRepo
15
13
{
16
14
get
@@ -45,11 +43,11 @@ public string RepoName
45
43
46
44
}
47
45
48
- private string workingDirectory ;
49
- public string WorkingDirectory
46
+ private string targetDirectory ;
47
+ public string TargetDirectory
50
48
{
51
- get => workingDirectory ;
52
- set => SetProperty ( ref workingDirectory , value ) ;
49
+ get => targetDirectory ;
50
+ set => SetProperty ( ref targetDirectory , value ) ;
53
51
54
52
}
55
53
@@ -70,57 +68,14 @@ public CloneRepoDialogViewModel(string repoUrl, string workingDirectory)
70
68
RepoName = string . Empty ;
71
69
}
72
70
73
- WorkingDirectory = workingDirectory ;
71
+ TargetDirectory = Path . Combine ( workingDirectory , RepoName ) ;
74
72
75
73
CloneRepoCommand = new AsyncRelayCommand ( DoCloneRepo ) ;
76
74
}
77
75
78
76
private async Task DoCloneRepo ( )
79
77
{
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 ) ;
124
79
}
125
80
}
126
81
}
0 commit comments