Fix/restore db files (#491)

* fixed an issue with target database name should replcae the original db name in the db file path
This commit is contained in:
Leila Lali
2017-10-11 14:48:51 -07:00
committed by GitHub
parent eab9339c14
commit 7fb09a0284

View File

@@ -795,10 +795,10 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
private string GetTargetDbFilePhysicalName(string sourceDbFilePhysicalLocation)
{
string fileName = Path.GetFileName(sourceDbFilePhysicalLocation);
if (!string.IsNullOrEmpty(this.DefaultSourceDbName) && !string.IsNullOrEmpty(this.targetDbName))
if (!string.IsNullOrEmpty(this.SourceDatabaseName) && !string.IsNullOrEmpty(this.targetDbName))
{
string sourceFilename = fileName;
fileName = sourceFilename.Replace(this.DefaultSourceDbName, this.targetDbName);
fileName = sourceFilename.Replace(this.SourceDatabaseName, this.targetDbName);
}
return fileName;
}
@@ -962,9 +962,11 @@ namespace Microsoft.SqlTools.ServiceLayer.DisasterRecovery.RestoreOperation
public bool ShouldCreateNewPlan()
{
return RestorePlan == null || string.Compare(RestorePlanner.DatabaseName, this.RestoreParams.GetOptionValue<string>(RestoreOptionsHelper.SourceDatabaseName), StringComparison.InvariantCultureIgnoreCase) != 0 ||
return RestorePlan == null ||
string.Compare(RestorePlanner.DatabaseName, this.RestoreParams.GetOptionValue<string>(RestoreOptionsHelper.SourceDatabaseName), StringComparison.InvariantCultureIgnoreCase) != 0 ||
RestorePlanner.ReadHeaderFromMedia != this.RestoreParams.ReadHeaderFromMedia ||
this.RelocateAllFiles != this.RestoreParams.GetOptionValue<bool>(RestoreOptionsHelper.RelocateDbFiles) ||
string.Compare(TargetDatabaseName, this.RestoreParams.GetOptionValue<string>(RestoreOptionsHelper.TargetDatabaseName), StringComparison.InvariantCultureIgnoreCase) != 0 ||
string.Compare(this.backupMediaList, RestoreParams.BackupFilePaths, StringComparison.InvariantCultureIgnoreCase) != 0;
}