Skip to content

Commit d2bf6b4

Browse files
committed
fix validation for restore file
1 parent 63ea921 commit d2bf6b4

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

MainWindow.Designer.cs

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MainWindow.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ private void OnFileOpenClick(object sender, EventArgs e)
100100
if (selected == DialogResult.OK)
101101
{
102102
SelectedFilelbl.Text = TargetLocation.FileName;
103-
if(string.IsNullOrWhiteSpace(DatabaseElem.Text))
103+
if (string.IsNullOrWhiteSpace(DatabaseElem.Text))
104104
{
105105
var fileName = TargetLocation.FileName.Split(new char[] { '/', '\\' }).LastOrDefault();
106-
if(fileName.Contains("_"))
106+
if (fileName.Contains("_"))
107107
{
108108
DatabaseElem.Text = fileName.Split('_').FirstOrDefault();
109109
}
@@ -124,7 +124,7 @@ private void OnRestore(object sender, EventArgs e)
124124
DatabaseName = DatabaseElem.Text.Trim(),
125125
ActionTypeValue = ActionSelectorElem.SelectedValue.ToString(),
126126
IsForPgDump = (TypeSelectorElem.SelectedValue.ToString() == CommandTypeConstants.PgDump.key),
127-
RestoreFileLocation = TargetLocation.FileName.Trim(),
127+
RestoreFileLocation = SelectedFilelbl.Text.Trim(),
128128
}
129129
.Validate();
130130

@@ -140,7 +140,7 @@ private void OnRestore(object sender, EventArgs e)
140140
{
141141
CommandExecutor.ExecuteRestore(connection);
142142
};
143-
143+
144144
bgw.RunWorkerCompleted += (object _, RunWorkerCompletedEventArgs args) =>
145145
{
146146
if (args.Error == null)
@@ -155,23 +155,25 @@ private void OnRestore(object sender, EventArgs e)
155155
}
156156
FinalizeLoadingFinished();
157157
};
158-
bgw.RunWorkerAsync();
158+
bgw.RunWorkerAsync();
159159
}
160160
catch (Exception ex)
161161
{
162-
MessageBox.Show(ex.Message,"Oops!",MessageBoxButtons.OK,MessageBoxIcon.Warning);
162+
MessageBox.Show(ex.Message, "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
163163
FinalizeLoadingFinished();
164164
}
165165
finally
166166
{
167167
Environment.SetEnvironmentVariable(PostgresConstants.PasswordKey, string.Empty);
168+
isRestoring = false;
168169
}
169170
}
170171

171172
private void FinalizeLoadingFinished()
172173
{
173174
EndLoading();
174-
SelectedFilelbl.Text = "No file Selected";
175+
SelectedFilelbl.Text = string.Empty;
176+
DatabaseElem.Text = string.Empty;
175177
RestoreBtn.Text = "⚒ Restore";
176178
isRestoring = false;
177179
}

MainWindow.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@
126126
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127127
<value>299, 11</value>
128128
</metadata>
129-
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130-
<value>299, 11</value>
131-
</metadata>
132129
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
133130
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
134131
<value>

0 commit comments

Comments
 (0)