mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
fixing a restore bug - relocating db files of a windows server db in mac (#546)
* fixed the bug with relocating db files in mac
This commit is contained in:
@@ -448,7 +448,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.dataFilesFolder = PathWrapper.GetDirectoryName(value + PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext));
|
this.dataFilesFolder = GetDirectoryName(value + PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(this.dataFilesFolder))
|
if (string.IsNullOrEmpty(this.dataFilesFolder))
|
||||||
{
|
{
|
||||||
@@ -496,7 +496,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.logFilesFolder = PathWrapper.GetDirectoryName(value + PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext));
|
this.logFilesFolder = GetDirectoryName(value + PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(this.logFilesFolder))
|
if (string.IsNullOrEmpty(this.logFilesFolder))
|
||||||
{
|
{
|
||||||
@@ -680,6 +680,27 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetDirectoryName(string filePath)
|
||||||
|
{
|
||||||
|
string localPath = ConvertToLocalMachinePath(filePath);
|
||||||
|
localPath = PathWrapper.GetDirectoryName(localPath);
|
||||||
|
return ConvertToServerConnectionPath(localPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConvertToLocalMachinePath(string filePath) {
|
||||||
|
string pathSeparator = Path.DirectorySeparatorChar.ToString();
|
||||||
|
string localPath = filePath.Replace("/", pathSeparator);
|
||||||
|
localPath = localPath.Replace("\\", pathSeparator);
|
||||||
|
return localPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConvertToServerConnectionPath(string filePath) {
|
||||||
|
string pathSeparator = PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext);
|
||||||
|
string serverPath = filePath.Replace("/", pathSeparator);
|
||||||
|
serverPath = serverPath.Replace("\\", pathSeparator);
|
||||||
|
return serverPath;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the Restore folder location of those db files whose orginal directory location
|
/// Updates the Restore folder location of those db files whose orginal directory location
|
||||||
/// is not present in the destination computer.
|
/// is not present in the destination computer.
|
||||||
@@ -812,10 +833,8 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetTargetDbFilePhysicalName(string sourceDbFilePhysicalLocation)
|
private string GetTargetDbFilePhysicalName(string sourceDbFilePhysicalLocation)
|
||||||
{
|
{
|
||||||
string pathSeparator = Path.DirectorySeparatorChar.ToString();
|
string filePath = ConvertToLocalMachinePath(sourceDbFilePhysicalLocation);
|
||||||
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("/", pathSeparator);
|
string fileName = Path.GetFileName(filePath);
|
||||||
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("\\", pathSeparator);
|
|
||||||
string fileName = Path.GetFileName(sourceDbFilePhysicalLocation);
|
|
||||||
if (!string.IsNullOrEmpty(this.SourceDatabaseName) && !string.IsNullOrEmpty(this.targetDbName))
|
if (!string.IsNullOrEmpty(this.SourceDatabaseName) && !string.IsNullOrEmpty(this.targetDbName))
|
||||||
{
|
{
|
||||||
string sourceFilename = fileName;
|
string sourceFilename = fileName;
|
||||||
|
|||||||
Reference in New Issue
Block a user