From 18ff0098741ee158ac38407e16131d00a98a3412 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Thu, 28 Mar 2013 11:58:41 -0400 Subject: [PATCH] Retries on extraction in installer --- MediaBrowser.Installer/MainWindow.xaml.cs | 28 ++++++++++++++++--- .../MediaBrowser.Installer.csproj | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.Installer/MainWindow.xaml.cs b/MediaBrowser.Installer/MainWindow.xaml.cs index 4826c3d22..3d60274b1 100644 --- a/MediaBrowser.Installer/MainWindow.xaml.cs +++ b/MediaBrowser.Installer/MainWindow.xaml.cs @@ -409,14 +409,34 @@ namespace MediaBrowser.Installer } // And extract - using (var fileStream = File.OpenRead(archive)) + var retryCount = 0; + var success = false; + while (!success && retryCount < 3) { - using (var zipFile = ZipFile.Read(fileStream)) + try { - zipFile.ExtractAll(RootPath, ExtractExistingFileAction.OverwriteSilently); + using (var fileStream = File.OpenRead(archive)) + { + using (var zipFile = ZipFile.Read(fileStream)) + { + zipFile.ExtractAll(RootPath, ExtractExistingFileAction.OverwriteSilently); + success = true; + } + } + } + catch + { + if (retryCount < 3) + { + Thread.Sleep(250); + retryCount++; + } + else + { + throw; + } } } - } /// diff --git a/MediaBrowser.Installer/MediaBrowser.Installer.csproj b/MediaBrowser.Installer/MediaBrowser.Installer.csproj index e5540966c..0c11ceb04 100644 --- a/MediaBrowser.Installer/MediaBrowser.Installer.csproj +++ b/MediaBrowser.Installer/MediaBrowser.Installer.csproj @@ -31,7 +31,7 @@ Media Browser Team Media Browser false - 51 + 53 0.1.1.%2a false true