@@ -12,7 +12,7 @@ class GitInstallDetails
12
12
public NPath GitLfsExecPath { get ; }
13
13
14
14
public const string GitExtractedMD5 = "e6cfc0c294a2312042f27f893dfc9c0a" ;
15
- public const string GitLfsExtractedMD5 = "ae968b69fbf42dff72311040d24a " ;
15
+ public const string GitLfsExtractedMD5 = "36e3ae968b69fbf42dff72311040d24a " ;
16
16
17
17
public const string WindowsGitLfsExecutableMD5 = "177bb14d0c08f665a24f0d5516c3b080" ;
18
18
public const string MacGitLfsExecutableMD5 = "f81a1a065a26a4123193e8fd96c561ad" ;
@@ -65,18 +65,27 @@ class GitInstaller
65
65
private readonly IZipHelper sharpZipLibHelper ;
66
66
private readonly CancellationToken cancellationToken ;
67
67
private readonly GitInstallDetails installDetails ;
68
+ private NPath gitArchiveFilePath ;
69
+ private NPath gitLfsArchivePath ;
68
70
69
71
public GitInstaller ( IEnvironment environment , CancellationToken cancellationToken , GitInstallDetails installDetails )
70
- : this ( environment , ZipHelper . Instance , cancellationToken , installDetails )
72
+ : this ( environment , ZipHelper . Instance , cancellationToken , installDetails , null , null )
71
73
{
72
74
}
73
75
74
- public GitInstaller ( IEnvironment environment , IZipHelper sharpZipLibHelper , CancellationToken cancellationToken , GitInstallDetails installDetails )
76
+ public GitInstaller ( IEnvironment environment , CancellationToken cancellationToken , GitInstallDetails installDetails , NPath gitArchiveFilePath , NPath gitLfsArchivePath )
77
+ : this ( environment , ZipHelper . Instance , cancellationToken , installDetails , gitArchiveFilePath , gitLfsArchivePath )
78
+ {
79
+ }
80
+
81
+ public GitInstaller ( IEnvironment environment , IZipHelper sharpZipLibHelper , CancellationToken cancellationToken , GitInstallDetails installDetails , NPath gitArchiveFilePath , NPath gitLfsArchivePath )
75
82
{
76
83
this . environment = environment ;
77
84
this . sharpZipLibHelper = sharpZipLibHelper ;
78
85
this . cancellationToken = cancellationToken ;
79
86
this . installDetails = installDetails ;
87
+ this . gitArchiveFilePath = gitArchiveFilePath ;
88
+ this . gitLfsArchivePath = gitLfsArchivePath ;
80
89
}
81
90
82
91
public void SetupGitIfNeeded ( ActionTask < NPath > onSuccess , ITask onFailure )
@@ -90,8 +99,7 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
90
99
}
91
100
92
101
new FuncTask < bool > ( cancellationToken , IsGitExtracted )
93
- . Then ( ( success , isPortableGitExtracted ) => {
94
-
102
+ . Finally ( ( success , ex , isPortableGitExtracted ) => {
95
103
Logger . Trace ( "IsPortableGitExtracted: {0}" , isPortableGitExtracted ) ;
96
104
97
105
if ( isPortableGitExtracted )
@@ -104,53 +112,33 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
104
112
}
105
113
else
106
114
{
107
- var tempZipPath = NPath . CreateTempDirectory ( "git_zip_paths" ) ;
108
- var gitArchivePath = tempZipPath . Combine ( "git.zip" ) ;
109
- var gitLfsArchivePath = tempZipPath . Combine ( "git-lfs.zip" ) ;
110
- var gitExtractPath = tempZipPath . Combine ( "git" ) . CreateDirectory ( ) ;
111
- var gitLfsExtractPath = tempZipPath . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
112
-
113
- var downloadGitMd5Task = new DownloadTextTask ( CancellationToken . None ,
114
- "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt" ) ;
115
-
116
- var downloadGitTask = new DownloadTask ( CancellationToken . None , environment . FileSystem ,
117
- "https://ghfvs-installer.github.com/unity/portable_git/git.zip" , gitArchivePath , retryCount : 1 ) ;
118
-
119
- var downloadGitLfsMd5Task = new DownloadTextTask ( CancellationToken . None ,
120
- "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt" ) ;
121
-
122
- var downloadGitLfsTask = new DownloadTask ( CancellationToken . None , environment . FileSystem ,
123
- "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip" , gitLfsArchivePath , retryCount : 1 ) ;
124
-
125
- downloadGitMd5Task
126
- . Then ( ( b , s ) =>
127
- {
128
- downloadGitTask . ValidationHash = s ;
129
- } )
130
- . Then ( downloadGitTask )
131
- . Then ( downloadGitLfsMd5Task )
132
- . Then ( ( b , s ) =>
133
- {
134
- downloadGitLfsTask . ValidationHash = s ;
135
- } )
136
- . Then ( downloadGitLfsTask )
137
- . Then ( new UnzipTask ( cancellationToken , gitArchivePath , gitExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitExtractedMD5 ) )
138
- . Then ( new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) )
115
+ ITask downloadFilesTask1 = null ;
116
+ if ( gitArchiveFilePath == null || gitLfsArchivePath == null )
117
+ {
118
+ downloadFilesTask1 = CreateDownloadTask ( ) ;
119
+ }
120
+
121
+ var tempZipExtractPath1 = NPath . CreateTempDirectory ( "git_zip_extract_zip_paths" ) ;
122
+ var gitExtractPath1 = tempZipExtractPath1 . Combine ( "git" ) . CreateDirectory ( ) ;
123
+ var gitLfsExtractPath1 = tempZipExtractPath1 . Combine ( "git-lfs" ) . CreateDirectory ( ) ;
124
+
125
+ var resultTask1 = new UnzipTask ( cancellationToken , gitArchiveFilePath , gitExtractPath1 , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitExtractedMD5 )
126
+ . Then ( new UnzipTask ( cancellationToken , gitLfsArchivePath , gitLfsExtractPath1 , sharpZipLibHelper , environment . FileSystem , GitInstallDetails . GitLfsExtractedMD5 ) )
139
127
. Then ( ( ) => {
140
- var targetGitLfsExecPath = installDetails . GetGitLfsExecPath ( gitExtractPath ) ;
141
- var extractGitLfsExePath = gitLfsExtractPath . Combine ( installDetails . GitLfsExec ) ;
142
- extractGitLfsExePath . Move ( targetGitLfsExecPath ) ;
128
+ var targetGitLfsExecPath1 = installDetails . GetGitLfsExecPath ( gitExtractPath1 ) ;
129
+ var extractGitLfsExePath1 = gitLfsExtractPath1 . Combine ( installDetails . GitLfsExec ) ;
130
+ extractGitLfsExePath1 . Move ( targetGitLfsExecPath1 ) ;
143
131
144
- Logger . Trace ( "Moving tempDirectory:\" {0}\" to extractTarget:\" {1}\" " , gitExtractPath ,
132
+ Logger . Trace ( "Moving tempDirectory:\" {0}\" to extractTarget:\" {1}\" " , gitExtractPath1 ,
145
133
installDetails . GitInstallPath ) ;
146
134
147
135
installDetails . GitInstallPath . EnsureParentDirectoryExists ( ) ;
148
- gitExtractPath . Move ( installDetails . GitInstallPath ) ;
149
-
150
- Logger . Trace ( "Deleting tempZipPath:\" {0}\" " , tempZipPath ) ;
151
- tempZipPath . DeleteIfExists ( ) ;
136
+ gitExtractPath1 . Move ( installDetails . GitInstallPath ) ;
152
137
153
- } ) . Finally ( ( b , exception ) => {
138
+ Logger . Trace ( "Deleting tempZipPath:\" {0}\" " , tempZipExtractPath1 ) ;
139
+ tempZipExtractPath1 . DeleteIfExists ( ) ;
140
+ } )
141
+ . Finally ( ( b , exception ) => {
154
142
if ( b )
155
143
{
156
144
Logger . Trace ( "SetupGitIfNeeded: Success" ) ;
@@ -165,12 +153,48 @@ public void SetupGitIfNeeded(ActionTask<NPath> onSuccess, ITask onFailure)
165
153
166
154
onFailure . Start ( ) ;
167
155
}
168
- } ) . Start ( ) ;
156
+ } ) ;
157
+
158
+ if ( downloadFilesTask1 != null )
159
+ {
160
+ resultTask1 = downloadFilesTask1 . Then ( resultTask1 ) ;
161
+ }
162
+
163
+ resultTask1 . Start ( ) ;
169
164
}
170
165
171
166
} ) . Start ( ) ;
172
167
}
173
168
169
+ private ITask CreateDownloadTask ( )
170
+ {
171
+ var tempZipPath = NPath . CreateTempDirectory ( "git_zip_paths" ) ;
172
+ gitArchiveFilePath = tempZipPath . Combine ( "git.zip" ) ;
173
+ gitLfsArchivePath = tempZipPath . Combine ( "git-lfs.zip" ) ;
174
+
175
+ var downloadGitMd5Task = new DownloadTextTask ( CancellationToken . None ,
176
+ "https://ghfvs-installer.github.com/unity/portable_git/git.zip.MD5.txt" ) ;
177
+
178
+ var downloadGitTask = new DownloadTask ( CancellationToken . None , environment . FileSystem ,
179
+ "https://ghfvs-installer.github.com/unity/portable_git/git.zip" , gitArchiveFilePath , retryCount : 1 ) ;
180
+
181
+ var downloadGitLfsMd5Task = new DownloadTextTask ( CancellationToken . None ,
182
+ "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip.MD5.txt" ) ;
183
+
184
+ var downloadGitLfsTask = new DownloadTask ( CancellationToken . None , environment . FileSystem ,
185
+ "https://ghfvs-installer.github.com/unity/portable_git/git-lfs.zip" , gitLfsArchivePath , retryCount : 1 ) ;
186
+
187
+ return downloadGitMd5Task . Then ( ( b , s ) => {
188
+ downloadGitTask . ValidationHash = s ;
189
+ } )
190
+ . Then ( downloadGitTask )
191
+ . Then ( downloadGitLfsMd5Task )
192
+ . Then ( ( b , s ) => {
193
+ downloadGitLfsTask . ValidationHash = s ;
194
+ } )
195
+ . Then ( downloadGitLfsTask ) ;
196
+ }
197
+
174
198
private bool IsGitExtracted ( )
175
199
{
176
200
if ( ! installDetails . GitInstallPath . DirectoryExists ( ) )
0 commit comments