fix the file path with the wrong path separator (#545)

* fix the file path with the wrong path separator

* fixed a typo
This commit is contained in:
Leila Lali
2017-11-06 12:12:52 -08:00
committed by Karl Burtram
parent 3bb86af10b
commit ba359e7a68

View File

@@ -637,7 +637,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
{
if (!string.IsNullOrEmpty(this.DataFilesFolder))
{
dbFile.PhysicalNameRelocate = PathWrapper.Combine(this.DataFilesFolder, fileName);
dbFile.PhysicalNameRelocate = CombineToServerConnectionPath(this.DataFilesFolder, fileName);
}
else
{
@@ -648,7 +648,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
{
if (!string.IsNullOrEmpty(this.LogFilesFolder))
{
dbFile.PhysicalNameRelocate = PathWrapper.Combine(this.LogFilesFolder, fileName);
dbFile.PhysicalNameRelocate = CombineToServerConnectionPath(this.LogFilesFolder, fileName);
}
else
{
@@ -663,6 +663,23 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
}
}
/// <summary>
/// Combining the root and file name using the server connection file path seperator
/// </summary>
private string CombineToServerConnectionPath(string root, string filePath)
{
string pathSeparatorFromServerConnection = PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext);
string combinedPath = PathWrapper.Combine(root, filePath);
// Make sure all path seperators are server connection separator
string result = combinedPath.Replace(Path.DirectorySeparatorChar.ToString(), pathSeparatorFromServerConnection);
// Make sure there's not any double file seperator in the path
result = result.Replace(pathSeparatorFromServerConnection + pathSeparatorFromServerConnection,
pathSeparatorFromServerConnection);
return result;
}
/// <summary>
/// Updates the Restore folder location of those db files whose orginal directory location
/// is not present in the destination computer.