Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions GVFS/GVFS.Common/FileSystem/PhysicalFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ public virtual void DeleteDirectory(string path, bool recursive = true)
directory.Delete();
}

public virtual void CopyDirectoryRecursive(string srcDirectoryPath, string dstDirectoryPath)
{
DirectoryInfo srcDirectory = new DirectoryInfo(srcDirectoryPath);

if (!this.DirectoryExists(dstDirectoryPath))
{
this.CreateDirectory(dstDirectoryPath);
}

foreach (FileInfo file in srcDirectory.EnumerateFiles())
{
this.CopyFile(file.FullName, Path.Combine(dstDirectoryPath, file.Name), overwrite: true);
}

foreach (DirectoryInfo subDirectory in srcDirectory.EnumerateDirectories())
{
this.CopyDirectoryRecursive(subDirectory.FullName, Path.Combine(dstDirectoryPath, subDirectory.Name));
}
}

public virtual bool FileExists(string path)
{
return File.Exists(path);
Expand Down
57 changes: 14 additions & 43 deletions GVFS/GVFS.Common/ProductUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,6 @@ public abstract class ProductUpgrader : IDisposable

private const string ToolsDirectory = "Tools";
private static readonly string UpgraderToolName = GVFSPlatform.Instance.Constants.GVFSUpgraderExecutableName;
private static readonly string UpgraderToolConfigFile = UpgraderToolName + ".config";
private static readonly string[] UpgraderToolAndLibs =
{
UpgraderToolName,
UpgraderToolConfigFile,
"GVFS.Common.dll",
"GVFS.Platform.Windows.dll",
"netstandard.dll",
"System.Net.Http.dll",
"Newtonsoft.Json.dll",
"CommandLine.dll",
"NuGet.Commands.dll",
"NuGet.Common.dll",
"NuGet.Configuration.dll",
"NuGet.Frameworks.dll",
"NuGet.Packaging.Core.dll",
"NuGet.Packaging.dll",
"NuGet.Protocol.dll",
"NuGet.Versioning.dll",
"System.IO.Compression.dll"
};

public ProductUpgrader(
string currentVersion,
Expand Down Expand Up @@ -196,29 +175,21 @@ public virtual bool TrySetupToolsDirectory(out string upgraderToolPath, out stri

string currentPath = ProcessHelper.GetCurrentProcessLocation();
error = null;
foreach (string name in UpgraderToolAndLibs)
try
{
string toolPath = Path.Combine(currentPath, name);
string destinationPath = Path.Combine(toolsDirectoryPath, name);
try
{
this.fileSystem.CopyFile(toolPath, destinationPath, overwrite: true);
}
catch (UnauthorizedAccessException e)
{
error = string.Join(
Environment.NewLine,
"File copy error - " + e.Message,
$"Make sure you have write permissions to directory {toolsDirectoryPath} and run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} again.");
this.TraceException(e, nameof(this.TrySetupToolsDirectory), $"Error copying {toolPath} to {destinationPath}.");
break;
}
catch (IOException e)
{
error = "File copy error - " + e.Message;
this.TraceException(e, nameof(this.TrySetupToolsDirectory), $"Error copying {toolPath} to {destinationPath}.");
break;
}
this.fileSystem.CopyDirectoryRecursive(currentPath, toolsDirectoryPath);
}
catch (UnauthorizedAccessException e)
{
error = string.Join(
Environment.NewLine,
"File copy error - " + e.Message,
$"Make sure you have write permissions to directory {toolsDirectoryPath} and run {GVFSConstants.UpgradeVerbMessages.GVFSUpgradeConfirm} again.");
}
catch (IOException e)
{
error = "File copy error - " + e.Message;
this.TraceException(e, nameof(this.TrySetupToolsDirectory), $"Error copying {currentPath} to {toolsDirectoryPath}.");
}

if (string.IsNullOrEmpty(error))
Expand Down