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 9393 <Compile Include="Application\ApplicationManagerBase.cs" />
9494 <Compile Include="Helpers\Constants.cs" />
9595 <Compile Include="Helpers\Validation.cs" />
96+ <Compile Include="Installer\CopyHelper.cs" />
9697 <Compile Include="Installer\GitInstaller.cs" />
9798 <Compile Include="Installer\OctorunInstaller.cs" />
9899 <Compile Include="Installer\UnzipTask.cs" />
Original file line number Diff line number Diff line change 104104 <Compile Include="Application\ApplicationManagerBase.cs" />
105105 <Compile Include="Helpers\Constants.cs" />
106106 <Compile Include="Helpers\Validation.cs" />
107+ <Compile Include="Installer\CopyHelper.cs" />
107108 <Compile Include="Installer\GitInstaller.cs" />
108109 <Compile Include="Installer\OctorunInstaller.cs" />
109110 <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)
307307 {
308308 Logger.Trace("Moving Git source:{0} target:{1}", source.ToString(), target.ToString());
309309
310- target.DeleteContents();
311- source.MoveFiles(target, true);
312- source.Parent.Delete();
310+ CopyHelper.Copy(source, target);
313311
314312 state.GitIsValid = true;
315313
@@ -335,9 +333,7 @@ private GitInstallationState ExtractGit(GitInstallationState state)
335333 {
336334 Logger.Trace("Moving GitLFS source:{0} target:{1}", source.ToString(), target.ToString());
337335
338- target.DeleteContents();
339- source.MoveFiles(target, true);
340- source.Parent.Delete();
336+ CopyHelper.Copy(source, target);
341337
342338 state.GitLfsIsValid = true;
343339 }
Original file line number Diff line number Diff line change @@ -55,9 +55,7 @@ private NPath MoveOctorun(NPath fromPath)
5555
5656 Logger.Trace("MoveOctorun fromPath: {0} toPath:{1}", fromPath.ToString(), toPath.ToString());
5757
58- toPath.DeleteContents();
59- fromPath.MoveFiles(toPath, true);
60- fromPath.Parent.Delete();
58+ CopyHelper.Copy(fromPath, toPath);
6159
6260 return installDetails.ExecutablePath;
6361 }
You can’t perform that action at this time.
0 commit comments