From cd0014aab574b4bb4341bdb57213948dd41ca428 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Mon, 4 Jul 2011 16:30:12 -0500 Subject: [PATCH] If the content server client fails to open a storage session, keep retrying. This behavior matches hldsupdatetool. --- DepotDownloader/ContentDownloader.cs | 33 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 0ffeec26..421a257a 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -14,6 +14,7 @@ namespace DepotDownloader static class ContentDownloader { const string DEFAULT_DIR = "depots"; + const int STORAGE_RETRY_COUNT = 500; static Steam3Session steam3; @@ -165,22 +166,28 @@ namespace DepotDownloader ContentServerClient csClient = new ContentServerClient(); - csClient.Connect( contentServer ); - - ContentServerClient.StorageSession session = null; - try - { - session = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, ( uint )cellId, credentials ); - } - catch ( Steam2Exception ex ) - { - Console.WriteLine( "Unable to open storage: " + ex.Message ); + int retryCount = 0; - if ( steam3 != null ) - steam3.Disconnect(); + while ( session == null ) + { + try + { + csClient.Connect( contentServer ); + session = csClient.OpenStorage( ( uint )depotId, ( uint )depotVersion, ( uint )cellId, credentials ); + } + catch ( Steam2Exception ex ) + { + csClient.Disconnect(); + retryCount++; - return; + if (retryCount > STORAGE_RETRY_COUNT) + { + if (steam3 != null) + steam3.Disconnect(); + return; + } + } } using ( session )