Skip to content

Commit dfc7a20

Browse files
author
xiebingkun
committed
download pdb if not exist pd_
1 parent e4e8f9a commit dfc7a20

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

pdbdownloader/MainWindow.xaml.cs

+42-17
Original file line numberDiff line numberDiff line change
@@ -259,24 +259,42 @@ private void DownloadProc()
259259

260260
}
261261
else if (e.Error != null)
262-
{
263-
m_Items[(int)e.UserState].ProgressColor = Brushes.Red;
262+
{
263+
if (m_Items[(int)e.UserState].PdbType == 0)
264+
{
265+
m_Items[(int)e.UserState].PdbType = 1;
266+
StringBuilder newUrl = new StringBuilder(m_Items[m_DownloadIndex].PdbUrl);
267+
newUrl[newUrl.Length - 1] = 'b';
268+
statusBarText.Dispatcher.Invoke(new Action(() => { statusBarText.Content = "Download: " + newUrl.ToString(); }));
269+
m_Items[m_DownloadIndex].ProgressColor = new SolidColorBrush(Color.FromArgb(0xff, 0x01, 0xd3, 0x28));
270+
m_Items[m_DownloadIndex].ProgressColor.Freeze();
271+
m_Downloader.DownloadFileAsync(new Uri(newUrl.ToString()), m_Items[m_DownloadIndex].PdbPath, m_DownloadIndex);
272+
return;
273+
}
274+
else
275+
{
276+
m_Items[(int)e.UserState].ProgressColor = Brushes.Red;
277+
}
278+
264279
}
265280
else
266-
{
267-
StringBuilder cab = new StringBuilder(m_Items[(int)e.UserState].PdbPath);
268-
cab[cab.Length - 1] = '_';
269-
270-
Process process = new Process();
271-
process.StartInfo.FileName = "expand.exe";
272-
process.StartInfo.Arguments = "expand.exe -R " + cab.ToString();
273-
process.StartInfo.CreateNoWindow = true;
274-
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
275-
process.Start();
276-
process.WaitForExit();
277-
File.Delete(cab.ToString());
278-
279-
m_Items[(int)e.UserState].ProgressColor = Brushes.Blue;
281+
{
282+
if (m_Items[(int)e.UserState].PdbType == 0)
283+
{
284+
StringBuilder cab = new StringBuilder(m_Items[(int)e.UserState].PdbPath);
285+
cab[cab.Length - 1] = '_';
286+
287+
Process process = new Process();
288+
process.StartInfo.FileName = "expand.exe";
289+
process.StartInfo.Arguments = "expand.exe -R " + cab.ToString();
290+
process.StartInfo.CreateNoWindow = true;
291+
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
292+
process.Start();
293+
process.WaitForExit();
294+
File.Delete(cab.ToString());
295+
296+
m_Items[(int)e.UserState].ProgressColor = Brushes.Blue;
297+
}
280298
}
281299

282300
ev.Set();
@@ -396,13 +414,20 @@ public string PdbUrl
396414
{
397415
get { return pdbUrl; }
398416
set { pdbUrl = value; }
417+
}
418+
private int pdbType;
419+
public int PdbType
420+
{
421+
get { return pdbType; }
422+
set { pdbType = value; }
399423
}
400424
public PdbItem(string filePath, string pdbPath, string pdbUrl, double progress)
401425
{
402426
PdbPath = pdbPath;
403427
FilePath = filePath;
404428
ProgressValue = progress;
405-
PdbUrl = pdbUrl;
429+
PdbUrl = pdbUrl;
430+
pdbType = 0;
406431
}
407432

408433
public event PropertyChangedEventHandler PropertyChanged;

0 commit comments

Comments
 (0)