47 lines
No EOL
1.9 KiB
C#
47 lines
No EOL
1.9 KiB
C#
using System;
|
|
using System.IO;
|
|
using Plume.Core.Logging;
|
|
|
|
namespace ShuttleInstaller.InstallerFromNas
|
|
{
|
|
public class NasShuttleInstaller : ShuttleInstaller
|
|
{
|
|
private readonly string _shuttleNasPath;
|
|
|
|
public NasShuttleInstaller(string shuttleNasPath)
|
|
{
|
|
_shuttleNasPath = shuttleNasPath ?? throw new ArgumentNullException(nameof(shuttleNasPath));
|
|
}
|
|
|
|
public override void InstallFiles(ILogger logger)
|
|
{
|
|
string shuttleVersionFolder = Path.Combine(_shuttleNasPath, ShuttleVersion);
|
|
if (!Directory.Exists(shuttleVersionFolder))
|
|
{
|
|
logger.Error($"Unable to find NAS directory at \"{shuttleVersionFolder}\".");
|
|
return;
|
|
}
|
|
|
|
// Create directories structure in destination
|
|
string sourceDirectory = Path.GetFullPath(shuttleVersionFolder);
|
|
var cepServerDirectories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.AllDirectories);
|
|
foreach (string directoryPath in cepServerDirectories)
|
|
{
|
|
string relativeDirectoryPath = directoryPath.Substring(sourceDirectory.Length + 1);
|
|
var destinationDirectory = Path.Combine(InstallationFolder, relativeDirectoryPath);
|
|
|
|
Directory.CreateDirectory(destinationDirectory);
|
|
}
|
|
|
|
// Actually copy files
|
|
var cepServerFiles = Directory.GetFiles(shuttleVersionFolder, "*.*", SearchOption.AllDirectories);
|
|
foreach (string sourceFilePath in cepServerFiles)
|
|
{
|
|
string relativeFilePath = sourceFilePath.Substring(sourceDirectory.Length +1);
|
|
string destinationFilePath = Path.Combine(InstallationFolder, relativeFilePath);
|
|
|
|
File.Copy(sourceFilePath, destinationFilePath, overwrite: true);
|
|
}
|
|
}
|
|
}
|
|
} |