This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +60
-9
lines changed Expand file tree Collapse file tree 5 files changed +60
-9
lines changed Original file line number Diff line number Diff line change 93
93
<Compile Include =" Application\ApplicationManagerBase.cs" />
94
94
<Compile Include =" Helpers\Constants.cs" />
95
95
<Compile Include =" Helpers\Validation.cs" />
96
+ <Compile Include =" Installer\CopyHelper.cs" />
96
97
<Compile Include =" Installer\GitInstaller.cs" />
97
98
<Compile Include =" Installer\OctorunInstaller.cs" />
98
99
<Compile Include =" Installer\UnzipTask.cs" />
Original file line number Diff line number Diff line change 104
104
<Compile Include =" Application\ApplicationManagerBase.cs" />
105
105
<Compile Include =" Helpers\Constants.cs" />
106
106
<Compile Include =" Helpers\Validation.cs" />
107
+ <Compile Include =" Installer\CopyHelper.cs" />
107
108
<Compile Include =" Installer\GitInstaller.cs" />
108
109
<Compile Include =" Installer\OctorunInstaller.cs" />
109
110
<Compile Include =" Installer\UnzipTask.cs" />
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Linq ;
4
+ using System . Text ;
5
+ using GitHub . Logging ;
6
+
7
+ namespace GitHub . Unity
8
+ {
9
+ public static class CopyHelper
10
+ {
11
+ private static readonly ILogging Logger = LogHelper . GetLogger ( typeof ( CopyHelper ) ) ;
12
+
13
+ public static void Copy ( NPath fromPath , NPath toPath )
14
+ {
15
+ try
16
+ {
17
+
18
+ CopyFolder ( fromPath , toPath ) ;
19
+ }
20
+ catch ( Exception ex1 )
21
+ {
22
+ Logger . Warning ( ex1 , "Error copying from " + fromPath + " to " + toPath + ". Attempting to copy contents." ) ;
23
+
24
+ try
25
+ {
26
+ CopyFolderContents ( fromPath , toPath ) ;
27
+ }
28
+ catch ( Exception ex2 )
29
+ {
30
+ Logger . Error ( ex2 , "Error copying from " + fromPath + " to " + toPath + "." ) ;
31
+ throw ;
32
+ }
33
+ }
34
+ finally
35
+ {
36
+ fromPath . DeleteIfExists ( ) ;
37
+ }
38
+ }
39
+ public static void CopyFolder ( NPath fromPath , NPath toPath )
40
+ {
41
+ Logger . Trace ( "CopyFolder fromPath: {0} toPath:{1}" , fromPath . ToString ( ) , toPath . ToString ( ) ) ;
42
+
43
+ toPath . EnsureParentDirectoryExists ( ) ;
44
+ fromPath . Move ( toPath ) ;
45
+ }
46
+
47
+ public static void CopyFolderContents ( NPath fromPath , NPath toPath )
48
+ {
49
+ Logger . Trace ( "CopyFolderContents fromPath: {0} toPath:{1}" , fromPath . ToString ( ) , toPath . ToString ( ) ) ;
50
+
51
+ toPath . DeleteContents ( ) ;
52
+ fromPath . MoveFiles ( toPath , true ) ;
53
+ }
54
+ }
55
+ }
Original file line number Diff line number Diff line change @@ -307,9 +307,7 @@ private GitInstallationState ExtractGit(GitInstallationState state)
307
307
{
308
308
Logger . Trace ( "Moving Git source:{0} target:{1}" , source . ToString ( ) , target . ToString ( ) ) ;
309
309
310
- target . DeleteContents ( ) ;
311
- source . MoveFiles ( target , true ) ;
312
- source . Parent . Delete ( ) ;
310
+ CopyHelper . Copy ( source , target ) ;
313
311
314
312
state . GitIsValid = true ;
315
313
@@ -335,9 +333,7 @@ private GitInstallationState ExtractGit(GitInstallationState state)
335
333
{
336
334
Logger . Trace ( "Moving GitLFS source:{0} target:{1}" , source . ToString ( ) , target . ToString ( ) ) ;
337
335
338
- target . DeleteContents ( ) ;
339
- source . MoveFiles ( target , true ) ;
340
- source . Parent . Delete ( ) ;
336
+ CopyHelper . Copy ( source , target ) ;
341
337
342
338
state . GitLfsIsValid = true ;
343
339
}
Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ private NPath MoveOctorun(NPath fromPath)
55
55
56
56
Logger . Trace ( "MoveOctorun fromPath: {0} toPath:{1}" , fromPath . ToString ( ) , toPath . ToString ( ) ) ;
57
57
58
- toPath . DeleteContents ( ) ;
59
- fromPath . MoveFiles ( toPath , true ) ;
60
- fromPath . Parent . Delete ( ) ;
58
+ CopyHelper . Copy ( fromPath , toPath ) ;
61
59
62
60
return installDetails . ExecutablePath ;
63
61
}
You can’t perform that action at this time.
0 commit comments