mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
fixed the issue with parsing a windows path was failing in mac (#503)
* fixed the issue with parsing a windows path was failing in mac
This commit is contained in:
@@ -32,20 +32,38 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
public RestoreConfigInfoResponse CreateConfigInfoResponse(RestoreConfigInfoRequestParams restoreConfigInfoRequest)
|
public RestoreConfigInfoResponse CreateConfigInfoResponse(RestoreConfigInfoRequestParams restoreConfigInfoRequest)
|
||||||
{
|
{
|
||||||
RestoreConfigInfoResponse response = new RestoreConfigInfoResponse();
|
RestoreConfigInfoResponse response = new RestoreConfigInfoResponse();
|
||||||
RestoreDatabaseTaskDataObject restoreTaskObject = CreateRestoreForNewSession(restoreConfigInfoRequest.OwnerUri);
|
RestoreDatabaseTaskDataObject restoreTaskObject = null;
|
||||||
if (restoreTaskObject != null)
|
|
||||||
{
|
|
||||||
// Default Data folder path in the target server
|
|
||||||
response.ConfigInfo.Add(RestoreOptionsHelper.DataFileFolder, restoreTaskObject.DefaultDataFileFolder);
|
|
||||||
// Default log folder path in the target server
|
|
||||||
response.ConfigInfo.Add(RestoreOptionsHelper.LogFileFolder, restoreTaskObject.DefaultLogFileFolder);
|
|
||||||
// The db names with backup set
|
|
||||||
response.ConfigInfo.Add(RestoreOptionsHelper.SourceDatabaseNamesWithBackupSets, restoreTaskObject.GetDatabaseNamesWithBackupSets());
|
|
||||||
// Default backup folder path in the target server
|
|
||||||
response.ConfigInfo.Add(RestoreOptionsHelper.DefaultBackupFolder, restoreTaskObject.DefaultBackupFolder);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
restoreTaskObject = CreateRestoreForNewSession(restoreConfigInfoRequest.OwnerUri);
|
||||||
|
if (restoreTaskObject != null)
|
||||||
|
{
|
||||||
|
// Default Data folder path in the target server
|
||||||
|
response.ConfigInfo.Add(RestoreOptionsHelper.DataFileFolder, restoreTaskObject.DefaultDataFileFolder);
|
||||||
|
// Default log folder path in the target server
|
||||||
|
response.ConfigInfo.Add(RestoreOptionsHelper.LogFileFolder, restoreTaskObject.DefaultLogFileFolder);
|
||||||
|
// The db names with backup set
|
||||||
|
response.ConfigInfo.Add(RestoreOptionsHelper.SourceDatabaseNamesWithBackupSets, restoreTaskObject.GetDatabaseNamesWithBackupSets());
|
||||||
|
// Default backup folder path in the target server
|
||||||
|
response.ConfigInfo.Add(RestoreOptionsHelper.DefaultBackupFolder, restoreTaskObject.DefaultBackupFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Write(LogLevel.Warning, $"Failed to create restore config info. error: { ex.Message}");
|
||||||
|
response.ErrorMessage = ex.Message;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
ServerConnection serverConnection = restoreTaskObject?.Server?.ConnectionContext;
|
||||||
|
if (serverConnection != null && serverConnection.IsOpen)
|
||||||
|
{
|
||||||
|
restoreTaskObject.Server.ConnectionContext.Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -174,23 +192,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
|
|
||||||
if (connInfo != null)
|
if (connInfo != null)
|
||||||
{
|
{
|
||||||
SqlConnection connection;
|
SqlConnection connection = ConnectionService.OpenSqlConnection(connInfo, "Restore");
|
||||||
DbConnection dbConnection = connInfo.AllConnections.First();
|
|
||||||
ReliableSqlConnection reliableSqlConnection = dbConnection as ReliableSqlConnection;
|
|
||||||
SqlConnection sqlConnection = dbConnection as SqlConnection;
|
|
||||||
if (reliableSqlConnection != null)
|
|
||||||
{
|
|
||||||
connection = reliableSqlConnection.GetUnderlyingConnection();
|
|
||||||
}
|
|
||||||
else if (sqlConnection != null)
|
|
||||||
{
|
|
||||||
connection = sqlConnection;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.Write(LogLevel.Warning, "Cannot find any sql connection for restore operation");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Server server = new Server(new ServerConnection(connection));
|
Server server = new Server(new ServerConnection(connection));
|
||||||
|
|
||||||
RestoreDatabaseTaskDataObject restoreDataObject = new RestoreDatabaseTaskDataObject(server, targetDatabaseName);
|
RestoreDatabaseTaskDataObject restoreDataObject = new RestoreDatabaseTaskDataObject(server, targetDatabaseName);
|
||||||
|
|||||||
@@ -794,7 +794,7 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private string GetTargetDbFilePhysicalName(string sourceDbFilePhysicalLocation)
|
private string GetTargetDbFilePhysicalName(string sourceDbFilePhysicalLocation)
|
||||||
{
|
{
|
||||||
string pathSeparator = PathWrapper.PathSeparatorFromServerConnection(Server.ConnectionContext);
|
string pathSeparator = Path.DirectorySeparatorChar.ToString();
|
||||||
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("/", pathSeparator);
|
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("/", pathSeparator);
|
||||||
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("\\", pathSeparator);
|
sourceDbFilePhysicalLocation = sourceDbFilePhysicalLocation.Replace("\\", pathSeparator);
|
||||||
string fileName = Path.GetFileName(sourceDbFilePhysicalLocation);
|
string fileName = Path.GetFileName(sourceDbFilePhysicalLocation);
|
||||||
|
|||||||
Reference in New Issue
Block a user