mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-19 17:23:55 -05:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user