Remove redundant code

pull/231/head
js6pak 5 years ago
parent 239d31441f
commit e9adf5b0f0
No known key found for this signature in database
GPG Key ID: EFE980EFD32F8EE9

@ -1,12 +1,10 @@
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using ProtoBuf;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.IO.IsolatedStorage; using System.IO.IsolatedStorage;
using System.Linq; using ProtoBuf;
using SteamKit2;
using SteamKit2.Discovery;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -17,17 +15,17 @@ namespace DepotDownloader
public Dictionary<string, byte[]> SentryData { get; private set; } public Dictionary<string, byte[]> SentryData { get; private set; }
[ ProtoMember( 2, IsRequired = false ) ] [ ProtoMember( 2, IsRequired = false ) ]
public System.Collections.Concurrent.ConcurrentDictionary<string, int> ContentServerPenalty { get; private set; } public ConcurrentDictionary<string, int> ContentServerPenalty { get; private set; }
[ ProtoMember( 3, IsRequired = false ) ] [ ProtoMember( 3, IsRequired = false ) ]
public Dictionary<string, string> LoginKeys { get; private set; } public Dictionary<string, string> LoginKeys { get; private set; }
string FileName = null; string FileName;
AccountSettingsStore() AccountSettingsStore()
{ {
SentryData = new Dictionary<string, byte[]>(); SentryData = new Dictionary<string, byte[]>();
ContentServerPenalty = new System.Collections.Concurrent.ConcurrentDictionary<string, int>(); ContentServerPenalty = new ConcurrentDictionary<string, int>();
LoginKeys = new Dictionary<string, string>(); LoginKeys = new Dictionary<string, string>();
} }
@ -36,7 +34,7 @@ namespace DepotDownloader
get { return Instance != null; } get { return Instance != null; }
} }
public static AccountSettingsStore Instance = null; public static AccountSettingsStore Instance;
static readonly IsolatedStorageFile IsolatedStorage = IsolatedStorageFile.GetUserStoreForAssembly(); static readonly IsolatedStorageFile IsolatedStorage = IsolatedStorageFile.GetUserStoreForAssembly();
public static void LoadFromFile( string filename ) public static void LoadFromFile( string filename )
@ -51,7 +49,7 @@ namespace DepotDownloader
using ( var fs = IsolatedStorage.OpenFile( filename, FileMode.Open, FileAccess.Read ) ) using ( var fs = IsolatedStorage.OpenFile( filename, FileMode.Open, FileAccess.Read ) )
using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Decompress ) ) using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Decompress ) )
{ {
Instance = ProtoBuf.Serializer.Deserialize<AccountSettingsStore>( ds ); Instance = Serializer.Deserialize<AccountSettingsStore>( ds );
} }
} }
catch ( IOException ex ) catch ( IOException ex )
@ -78,7 +76,7 @@ namespace DepotDownloader
using ( var fs = IsolatedStorage.OpenFile( Instance.FileName, FileMode.Create, FileAccess.Write ) ) using ( var fs = IsolatedStorage.OpenFile( Instance.FileName, FileMode.Create, FileAccess.Write ) )
using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Compress ) ) using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Compress ) )
{ {
ProtoBuf.Serializer.Serialize<AccountSettingsStore>( ds, Instance ); Serializer.Serialize( ds, Instance );
} }
} }
catch ( IOException ex ) catch ( IOException ex )

@ -1,11 +1,11 @@
using SteamKit2; using System;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SteamKit2;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -165,11 +165,9 @@ namespace DepotDownloader
var result = await authTokenCallbackPromise.Task; var result = await authTokenCallbackPromise.Task;
return result.Token; return result.Token;
} }
else
{
throw new Exception( $"Failed to retrieve CDN token for server {server.Host} depot {depotId}" ); throw new Exception( $"Failed to retrieve CDN token for server {server.Host} depot {depotId}" );
} }
}
public void ReturnConnection( CDNClient.Server server ) public void ReturnConnection( CDNClient.Server server )
{ {

@ -1,19 +1,17 @@
using SteamKit2; using System;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SteamKit2;
namespace DepotDownloader namespace DepotDownloader
{ {
public class ContentDownloaderException : System.Exception public class ContentDownloaderException : Exception
{ {
public ContentDownloaderException( String value ) : base( value ) { } public ContentDownloaderException( String value ) : base( value ) { }
} }
@ -58,7 +56,7 @@ namespace DepotDownloader
installDir = null; installDir = null;
try try
{ {
if ( string.IsNullOrWhiteSpace( ContentDownloader.Config.InstallDirectory ) ) if ( string.IsNullOrWhiteSpace( Config.InstallDirectory ) )
{ {
Directory.CreateDirectory( DEFAULT_DOWNLOAD_DIR ); Directory.CreateDirectory( DEFAULT_DOWNLOAD_DIR );
@ -73,9 +71,9 @@ namespace DepotDownloader
} }
else else
{ {
Directory.CreateDirectory( ContentDownloader.Config.InstallDirectory ); Directory.CreateDirectory( Config.InstallDirectory );
installDir = ContentDownloader.Config.InstallDirectory; installDir = Config.InstallDirectory;
Directory.CreateDirectory( Path.Combine( installDir, CONFIG_DIR ) ); Directory.CreateDirectory( Path.Combine( installDir, CONFIG_DIR ) );
Directory.CreateDirectory( Path.Combine( installDir, STAGING_DIR ) ); Directory.CreateDirectory( Path.Combine( installDir, STAGING_DIR ) );
@ -120,7 +118,7 @@ namespace DepotDownloader
IEnumerable<uint> licenseQuery; IEnumerable<uint> licenseQuery;
if ( steam3.steamUser.SteamID.AccountType == EAccountType.AnonUser ) if ( steam3.steamUser.SteamID.AccountType == EAccountType.AnonUser )
{ {
licenseQuery = new List<uint>() { 17906 }; licenseQuery = new List<uint> { 17906 };
} }
else else
{ {
@ -189,7 +187,7 @@ namespace DepotDownloader
return 0; return 0;
KeyValue depots = ContentDownloader.GetSteam3AppSection( appId, EAppInfoSection.Depots ); KeyValue depots = GetSteam3AppSection( appId, EAppInfoSection.Depots );
KeyValue branches = depots[ "branches" ]; KeyValue branches = depots[ "branches" ];
KeyValue node = branches[ branch ]; KeyValue node = branches[ branch ];
@ -267,7 +265,8 @@ namespace DepotDownloader
return BitConverter.ToUInt64( manifest_bytes, 0 ); return BitConverter.ToUInt64( manifest_bytes, 0 );
} }
else if ( encrypted_v2 != KeyValue.Invalid )
if ( encrypted_v2 != KeyValue.Invalid )
{ {
// Submit the password to Steam now to get encryption keys // Submit the password to Steam now to get encryption keys
steam3.CheckAppBetaPassword( appId, Config.BetaPassword ); steam3.CheckAppBetaPassword( appId, Config.BetaPassword );
@ -292,12 +291,10 @@ namespace DepotDownloader
return BitConverter.ToUInt64( manifest_bytes, 0 ); return BitConverter.ToUInt64( manifest_bytes, 0 );
} }
else
{
Console.WriteLine( "Unhandled depot encryption for depotId {0}", depotId ); Console.WriteLine( "Unhandled depot encryption for depotId {0}", depotId );
return INVALID_MANIFEST_ID; return INVALID_MANIFEST_ID;
} }
}
return INVALID_MANIFEST_ID; return INVALID_MANIFEST_ID;
} }
@ -319,8 +316,7 @@ namespace DepotDownloader
return info[ "name" ].AsString(); return info[ "name" ].AsString();
} }
else
{
KeyValue depots = GetSteam3AppSection( appId, EAppInfoSection.Depots ); KeyValue depots = GetSteam3AppSection( appId, EAppInfoSection.Depots );
if ( depots == null ) if ( depots == null )
@ -333,7 +329,6 @@ namespace DepotDownloader
return depotChild[ "name" ].AsString(); return depotChild[ "name" ].AsString();
} }
}
public static bool InitializeSteam3( string username, string password ) public static bool InitializeSteam3( string username, string password )
{ {
@ -345,7 +340,7 @@ namespace DepotDownloader
} }
steam3 = new Steam3Session( steam3 = new Steam3Session(
new SteamUser.LogOnDetails() new SteamUser.LogOnDetails
{ {
Username = username, Username = username,
Password = loginKey == null ? password : null, Password = loginKey == null ? password : null,
@ -391,7 +386,7 @@ namespace DepotDownloader
} }
else if ( details?.hcontent_file > 0 ) else if ( details?.hcontent_file > 0 )
{ {
await DownloadAppAsync( appId, new List<(uint, ulong)>() { ( appId, details.hcontent_file ) }, DEFAULT_BRANCH, null, null, null, false, true ); await DownloadAppAsync( appId, new List<(uint, ulong)> { ( appId, details.hcontent_file ) }, DEFAULT_BRANCH, null, null, null, false, true );
} }
else else
{ {
@ -418,7 +413,7 @@ namespace DepotDownloader
} }
else else
{ {
await DownloadAppAsync( appId, new List<(uint, ulong)>() { ( appId, ugcId ) }, DEFAULT_BRANCH, null, null, null, false, true ); await DownloadAppAsync( appId, new List<(uint, ulong)> { ( appId, ugcId ) }, DEFAULT_BRANCH, null, null, null, false, true );
} }
} }
@ -459,7 +454,7 @@ namespace DepotDownloader
cdnPool = new CDNClientPool( steam3, appId ); cdnPool = new CDNClientPool( steam3, appId );
// Load our configuration data containing the depots currently installed // Load our configuration data containing the depots currently installed
string configPath = ContentDownloader.Config.InstallDirectory; string configPath = Config.InstallDirectory;
if ( string.IsNullOrWhiteSpace( configPath ) ) if ( string.IsNullOrWhiteSpace( configPath ) )
{ {
configPath = DEFAULT_DOWNLOAD_DIR; configPath = DEFAULT_DOWNLOAD_DIR;
@ -562,7 +557,7 @@ namespace DepotDownloader
depotIdsFound.Add( id ); depotIdsFound.Add( id );
if ( !hasSpecificDepots ) if ( !hasSpecificDepots )
depotManifestIds.Add( ( id, ContentDownloader.INVALID_MANIFEST_ID ) ); depotManifestIds.Add( ( id, INVALID_MANIFEST_ID ) );
} }
} }
@ -570,7 +565,8 @@ namespace DepotDownloader
{ {
throw new ContentDownloaderException( String.Format( "Couldn't find any depots to download for app {0}", appId ) ); throw new ContentDownloaderException( String.Format( "Couldn't find any depots to download for app {0}", appId ) );
} }
else if ( depotIdsFound.Count < depotIdsExpected.Count )
if ( depotIdsFound.Count < depotIdsExpected.Count )
{ {
var remainingDepotIds = depotIdsExpected.Except( depotIdsFound ); var remainingDepotIds = depotIdsExpected.Except( depotIdsFound );
throw new ContentDownloaderException( String.Format( "Depot {0} not listed for app {1}", string.Join( ", ", remainingDepotIds ), appId ) ); throw new ContentDownloaderException( String.Format( "Depot {0} not listed for app {1}", string.Join( ", ", remainingDepotIds ), appId ) );
@ -602,7 +598,7 @@ namespace DepotDownloader
static DepotDownloadInfo GetDepotInfo( uint depotId, uint appId, ulong manifestId, string branch ) static DepotDownloadInfo GetDepotInfo( uint depotId, uint appId, ulong manifestId, string branch )
{ {
if ( steam3 != null && appId != INVALID_APP_ID ) if ( steam3 != null && appId != INVALID_APP_ID )
steam3.RequestAppInfo( ( uint )appId ); steam3.RequestAppInfo( appId );
string contentName = GetAppOrDepotName( depotId, appId ); string contentName = GetAppOrDepotName( depotId, appId );
@ -722,7 +718,7 @@ namespace DepotDownloader
// If we're about to write all the files to the same directory, we will need to first de-duplicate any files by path // If we're about to write all the files to the same directory, we will need to first de-duplicate any files by path
// This is in last-depot-wins order, from Steam or the list of depots supplied by the user // This is in last-depot-wins order, from Steam or the list of depots supplied by the user
if ( !string.IsNullOrWhiteSpace( ContentDownloader.Config.InstallDirectory ) && depotsToDownload.Count > 0 ) if ( !string.IsNullOrWhiteSpace( Config.InstallDirectory ) && depotsToDownload.Count > 0 )
{ {
var claimedFileNames = new HashSet<String>(); var claimedFileNames = new HashSet<String>();
@ -863,16 +859,15 @@ namespace DepotDownloader
Console.WriteLine( "Encountered 401 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId ); Console.WriteLine( "Encountered 401 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId );
break; break;
} }
else if ( e.StatusCode == HttpStatusCode.NotFound )
if ( e.StatusCode == HttpStatusCode.NotFound )
{ {
Console.WriteLine( "Encountered 404 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId ); Console.WriteLine( "Encountered 404 for depot manifest {0} {1}. Aborting.", depot.id, depot.manifestId );
break; break;
} }
else
{
Console.WriteLine( "Encountered error downloading depot manifest {0} {1}: {2}", depot.id, depot.manifestId, e.StatusCode ); Console.WriteLine( "Encountered error downloading depot manifest {0} {1}: {2}", depot.id, depot.manifestId, e.StatusCode );
} }
}
catch ( OperationCanceledException ) catch ( OperationCanceledException )
{ {
break; break;
@ -983,7 +978,7 @@ namespace DepotDownloader
var previousFilteredFiles = depotFilesData.previousManifest.Files.AsParallel().Where( f => TestIsFileIncluded( f.FileName ) ).Select( f => f.FileName ).ToHashSet(); var previousFilteredFiles = depotFilesData.previousManifest.Files.AsParallel().Where( f => TestIsFileIncluded( f.FileName ) ).Select( f => f.FileName ).ToHashSet();
// Check if we are writing to a single output directory. If not, each depot folder is managed independently // Check if we are writing to a single output directory. If not, each depot folder is managed independently
if ( string.IsNullOrWhiteSpace( ContentDownloader.Config.InstallDirectory ) ) if ( string.IsNullOrWhiteSpace( Config.InstallDirectory ) )
{ {
// Of the list of files in the previous manifest, remove any file names that exist in the current set of all file names // Of the list of files in the previous manifest, remove any file names that exist in the current set of all file names
previousFilteredFiles.ExceptWith( depotFilesData.allFileNames ); previousFilteredFiles.ExceptWith( depotFilesData.allFileNames );
@ -1173,23 +1168,21 @@ namespace DepotDownloader
{ {
lock ( depotDownloadCounter ) lock ( depotDownloadCounter )
{ {
depotDownloadCounter.SizeDownloaded += ( ulong )file.TotalSize; depotDownloadCounter.SizeDownloaded += file.TotalSize;
Console.WriteLine( "{0,6:#00.00}% {1}", ( ( float )depotDownloadCounter.SizeDownloaded / ( float )depotDownloadCounter.CompleteDownloadSize ) * 100.0f, fileFinalPath ); Console.WriteLine( "{0,6:#00.00}% {1}", ( depotDownloadCounter.SizeDownloaded / ( float )depotDownloadCounter.CompleteDownloadSize ) * 100.0f, fileFinalPath );
} }
if ( fs != null ) if ( fs != null )
fs.Dispose(); fs.Dispose();
return; return;
} }
else
{
var sizeOnDisk = ( file.TotalSize - ( ulong )neededChunks.Select( x => ( long )x.UncompressedLength ).Sum() ); var sizeOnDisk = ( file.TotalSize - ( ulong )neededChunks.Select( x => ( long )x.UncompressedLength ).Sum() );
lock ( depotDownloadCounter ) lock ( depotDownloadCounter )
{ {
depotDownloadCounter.SizeDownloaded += sizeOnDisk; depotDownloadCounter.SizeDownloaded += sizeOnDisk;
} }
} }
}
FileStreamData fileStreamData = new FileStreamData FileStreamData fileStreamData = new FileStreamData
{ {
@ -1260,11 +1253,9 @@ namespace DepotDownloader
Console.WriteLine( "Encountered 401 for chunk {0}. Aborting.", chunkID ); Console.WriteLine( "Encountered 401 for chunk {0}. Aborting.", chunkID );
break; break;
} }
else
{
Console.WriteLine( "Encountered error downloading chunk {0}: {1}", chunkID, e.StatusCode ); Console.WriteLine( "Encountered error downloading chunk {0}: {1}", chunkID, e.StatusCode );
} }
}
catch ( OperationCanceledException ) catch ( OperationCanceledException )
{ {
break; break;
@ -1322,7 +1313,7 @@ namespace DepotDownloader
if ( remainingChunks == 0 ) if ( remainingChunks == 0 )
{ {
var fileFinalPath = Path.Combine( depot.installDir, file.FileName ); var fileFinalPath = Path.Combine( depot.installDir, file.FileName );
Console.WriteLine( "{0,6:#00.00}% {1}", ( ( float )sizeDownloaded / ( float )depotDownloadCounter.CompleteDownloadSize ) * 100.0f, fileFinalPath ); Console.WriteLine( "{0,6:#00.00}% {1}", ( sizeDownloaded / ( float )depotDownloadCounter.CompleteDownloadSize ) * 100.0f, fileFinalPath );
} }
} }

@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ProtoBuf;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using ProtoBuf;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -12,7 +12,7 @@ namespace DepotDownloader
[ ProtoMember( 1 ) ] [ ProtoMember( 1 ) ]
public Dictionary<uint, ulong> InstalledManifestIDs { get; private set; } public Dictionary<uint, ulong> InstalledManifestIDs { get; private set; }
string FileName = null; string FileName;
DepotConfigStore() DepotConfigStore()
{ {
@ -24,7 +24,7 @@ namespace DepotDownloader
get { return Instance != null; } get { return Instance != null; }
} }
public static DepotConfigStore Instance = null; public static DepotConfigStore Instance;
public static void LoadFromFile( string filename ) public static void LoadFromFile( string filename )
{ {
@ -35,7 +35,7 @@ namespace DepotDownloader
{ {
using ( FileStream fs = File.Open( filename, FileMode.Open ) ) using ( FileStream fs = File.Open( filename, FileMode.Open ) )
using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Decompress ) ) using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Decompress ) )
Instance = ProtoBuf.Serializer.Deserialize<DepotConfigStore>( ds ); Instance = Serializer.Deserialize<DepotConfigStore>( ds );
} }
else else
{ {
@ -52,7 +52,7 @@ namespace DepotDownloader
using ( FileStream fs = File.Open( Instance.FileName, FileMode.Create ) ) using ( FileStream fs = File.Open( Instance.FileName, FileMode.Create ) )
using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Compress ) ) using ( DeflateStream ds = new DeflateStream( fs, CompressionMode.Compress ) )
ProtoBuf.Serializer.Serialize<DepotConfigStore>( ds, Instance ); Serializer.Serialize( ds, Instance );
} }
} }
} }

@ -1,11 +1,7 @@
using System; using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;

@ -1,11 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using SteamKit2;
using System.ComponentModel;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq; using SteamKit2;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -45,7 +45,7 @@ namespace DepotDownloader
ContentDownloader.Config.DownloadManifestOnly = HasParameter( args, "-manifest-only" ); ContentDownloader.Config.DownloadManifestOnly = HasParameter( args, "-manifest-only" );
int cellId = GetParameter<int>( args, "-cellid", -1 ); int cellId = GetParameter( args, "-cellid", -1 );
if ( cellId == -1 ) if ( cellId == -1 )
{ {
cellId = 0; cellId = 0;
@ -60,7 +60,7 @@ namespace DepotDownloader
try try
{ {
string fileListData = await File.ReadAllTextAsync( fileList ); string fileListData = await File.ReadAllTextAsync( fileList );
var files = fileListData.Split( new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries ); var files = fileListData.Split( new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries );
ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.UsingFileList = true;
ContentDownloader.Config.FilesToDownload = new HashSet<string>( StringComparer.OrdinalIgnoreCase ); ContentDownloader.Config.FilesToDownload = new HashSet<string>( StringComparer.OrdinalIgnoreCase );
@ -83,29 +83,29 @@ namespace DepotDownloader
} }
catch ( Exception ex ) catch ( Exception ex )
{ {
Console.WriteLine( "Warning: Unable to load filelist: {0}", ex.ToString() ); Console.WriteLine( "Warning: Unable to load filelist: {0}", ex );
} }
} }
ContentDownloader.Config.InstallDirectory = GetParameter<string>( args, "-dir" ); ContentDownloader.Config.InstallDirectory = GetParameter<string>( args, "-dir" );
ContentDownloader.Config.VerifyAll = HasParameter( args, "-verify-all" ) || HasParameter( args, "-verify_all" ) || HasParameter( args, "-validate" ); ContentDownloader.Config.VerifyAll = HasParameter( args, "-verify-all" ) || HasParameter( args, "-verify_all" ) || HasParameter( args, "-validate" );
ContentDownloader.Config.MaxServers = GetParameter<int>( args, "-max-servers", 20 ); ContentDownloader.Config.MaxServers = GetParameter( args, "-max-servers", 20 );
ContentDownloader.Config.MaxDownloads = GetParameter<int>( args, "-max-downloads", 8 ); ContentDownloader.Config.MaxDownloads = GetParameter( args, "-max-downloads", 8 );
ContentDownloader.Config.MaxServers = Math.Max( ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads ); ContentDownloader.Config.MaxServers = Math.Max( ContentDownloader.Config.MaxServers, ContentDownloader.Config.MaxDownloads );
ContentDownloader.Config.LoginID = HasParameter( args, "-loginid" ) ? ( uint? )GetParameter<uint>( args, "-loginid" ) : null; ContentDownloader.Config.LoginID = HasParameter( args, "-loginid" ) ? GetParameter<uint>( args, "-loginid" ) : null;
#endregion #endregion
uint appId = GetParameter<uint>( args, "-app", ContentDownloader.INVALID_APP_ID ); uint appId = GetParameter( args, "-app", ContentDownloader.INVALID_APP_ID );
if ( appId == ContentDownloader.INVALID_APP_ID ) if ( appId == ContentDownloader.INVALID_APP_ID )
{ {
Console.WriteLine( "Error: -app not specified!" ); Console.WriteLine( "Error: -app not specified!" );
return 1; return 1;
} }
ulong pubFile = GetParameter<ulong>( args, "-pubfile", ContentDownloader.INVALID_MANIFEST_ID ); ulong pubFile = GetParameter( args, "-pubfile", ContentDownloader.INVALID_MANIFEST_ID );
ulong ugcId = GetParameter<ulong>( args, "-ugc", ContentDownloader.INVALID_MANIFEST_ID ); ulong ugcId = GetParameter( args, "-ugc", ContentDownloader.INVALID_MANIFEST_ID );
if ( pubFile != ContentDownloader.INVALID_MANIFEST_ID ) if ( pubFile != ContentDownloader.INVALID_MANIFEST_ID )
{ {
#region Pubfile Downloading #region Pubfile Downloading
@ -184,7 +184,7 @@ namespace DepotDownloader
ContentDownloader.Config.BetaPassword = GetParameter<string>( args, "-betapassword" ); ContentDownloader.Config.BetaPassword = GetParameter<string>( args, "-betapassword" );
ContentDownloader.Config.DownloadAllPlatforms = HasParameter( args, "-all-platforms" ); ContentDownloader.Config.DownloadAllPlatforms = HasParameter( args, "-all-platforms" );
string os = GetParameter<string>( args, "-os", null ); string os = GetParameter<string>( args, "-os" );
if ( ContentDownloader.Config.DownloadAllPlatforms && !String.IsNullOrEmpty( os ) ) if ( ContentDownloader.Config.DownloadAllPlatforms && !String.IsNullOrEmpty( os ) )
{ {
@ -192,10 +192,10 @@ namespace DepotDownloader
return 1; return 1;
} }
string arch = GetParameter<string>( args, "-osarch", null ); string arch = GetParameter<string>( args, "-osarch" );
ContentDownloader.Config.DownloadAllLanguages = HasParameter( args, "-all-languages" ); ContentDownloader.Config.DownloadAllLanguages = HasParameter( args, "-all-languages" );
string language = GetParameter<string>( args, "-language", null ); string language = GetParameter<string>( args, "-language" );
if ( ContentDownloader.Config.DownloadAllLanguages && !String.IsNullOrEmpty( language ) ) if ( ContentDownloader.Config.DownloadAllLanguages && !String.IsNullOrEmpty( language ) )
{ {

@ -7,7 +7,7 @@ using SteamKit2;
namespace DepotDownloader namespace DepotDownloader
{ {
[ ProtoContract() ] [ ProtoContract ]
class ProtoManifest class ProtoManifest
{ {
// Proto ctor // Proto ctor
@ -23,7 +23,7 @@ namespace DepotDownloader
CreationTime = sourceManifest.CreationTime; CreationTime = sourceManifest.CreationTime;
} }
[ ProtoContract() ] [ ProtoContract ]
public class FileData public class FileData
{ {
// Proto ctor // Proto ctor
@ -138,7 +138,7 @@ namespace DepotDownloader
checksum = Util.SHAHash( ms.ToArray() ); checksum = Util.SHAHash( ms.ToArray() );
ms.Seek( 0, SeekOrigin.Begin ); ms.Seek( 0, SeekOrigin.Begin );
return ProtoBuf.Serializer.Deserialize<ProtoManifest>( ms ); return Serializer.Deserialize<ProtoManifest>( ms );
} }
} }
@ -146,7 +146,7 @@ namespace DepotDownloader
{ {
using ( MemoryStream ms = new MemoryStream() ) using ( MemoryStream ms = new MemoryStream() )
{ {
ProtoBuf.Serializer.Serialize<ProtoManifest>( ms, this ); Serializer.Serialize( ms, this );
checksum = Util.SHAHash( ms.ToArray() ); checksum = Util.SHAHash( ms.ToArray() );

@ -1,6 +1,4 @@
using SteamKit2; using System;
using SteamKit2.Internal;
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
@ -8,6 +6,8 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using SteamKit2;
using SteamKit2.Internal;
namespace DepotDownloader namespace DepotDownloader
{ {
@ -175,7 +175,7 @@ namespace DepotDownloader
return; return;
bool completed = false; bool completed = false;
Action<SteamApps.PICSTokensCallback> cbMethodTokens = ( appTokens ) => Action<SteamApps.PICSTokensCallback> cbMethodTokens = appTokens =>
{ {
completed = true; completed = true;
if ( appTokens.AppTokensDenied.Contains( appId ) ) if ( appTokens.AppTokensDenied.Contains( appId ) )
@ -191,11 +191,11 @@ namespace DepotDownloader
WaitUntilCallback( () => WaitUntilCallback( () =>
{ {
callbacks.Subscribe( steamApps.PICSGetAccessTokens( new List<uint>() { appId }, new List<uint>() { } ), cbMethodTokens ); callbacks.Subscribe( steamApps.PICSGetAccessTokens( new List<uint> { appId }, new List<uint>() ), cbMethodTokens );
}, () => { return completed; } ); }, () => { return completed; } );
completed = false; completed = false;
Action<SteamApps.PICSProductInfoCallback> cbMethod = ( appInfo ) => Action<SteamApps.PICSProductInfoCallback> cbMethod = appInfo =>
{ {
completed = !appInfo.ResponsePending; completed = !appInfo.ResponsePending;
@ -222,7 +222,7 @@ namespace DepotDownloader
WaitUntilCallback( () => WaitUntilCallback( () =>
{ {
callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<SteamApps.PICSRequest>() { request }, new List<SteamApps.PICSRequest>() { } ), cbMethod ); callbacks.Subscribe( steamApps.PICSGetProductInfo( new List<SteamApps.PICSRequest> { request }, new List<SteamApps.PICSRequest>() ), cbMethod );
}, () => { return completed; } ); }, () => { return completed; } );
} }
@ -235,7 +235,7 @@ namespace DepotDownloader
return; return;
bool completed = false; bool completed = false;
Action<SteamApps.PICSProductInfoCallback> cbMethod = ( packageInfo ) => Action<SteamApps.PICSProductInfoCallback> cbMethod = packageInfo =>
{ {
completed = !packageInfo.ResponsePending; completed = !packageInfo.ResponsePending;
@ -276,7 +276,7 @@ namespace DepotDownloader
{ {
bool success = false; bool success = false;
bool completed = false; bool completed = false;
Action<SteamApps.FreeLicenseCallback> cbMethod = ( resultInfo ) => Action<SteamApps.FreeLicenseCallback> cbMethod = resultInfo =>
{ {
completed = true; completed = true;
success = resultInfo.GrantedApps.Contains( appId ); success = resultInfo.GrantedApps.Contains( appId );
@ -297,7 +297,7 @@ namespace DepotDownloader
bool completed = false; bool completed = false;
Action<SteamApps.DepotKeyCallback> cbMethod = ( depotKey ) => Action<SteamApps.DepotKeyCallback> cbMethod = depotKey =>
{ {
completed = true; completed = true;
Console.WriteLine( "Got depot key for {0} result: {1}", depotKey.DepotID, depotKey.Result ); Console.WriteLine( "Got depot key for {0} result: {1}", depotKey.DepotID, depotKey.Result );
@ -324,7 +324,8 @@ namespace DepotDownloader
{ {
return "steampipe.steamcontent.com"; return "steampipe.steamcontent.com";
} }
else if ( host.EndsWith( ".steamcontent.com" ) )
if ( host.EndsWith( ".steamcontent.com" ) )
{ {
return "steamcontent.com"; return "steamcontent.com";
} }
@ -342,7 +343,7 @@ namespace DepotDownloader
bool completed = false; bool completed = false;
var timeoutDate = DateTime.Now.AddSeconds( 10 ); var timeoutDate = DateTime.Now.AddSeconds( 10 );
Action<SteamApps.CDNAuthTokenCallback> cbMethod = ( cdnAuth ) => Action<SteamApps.CDNAuthTokenCallback> cbMethod = cdnAuth =>
{ {
completed = true; completed = true;
Console.WriteLine( "Got CDN auth token for {0} result: {1} (expires {2})", host, cdnAuth.Result, cdnAuth.Expiration ); Console.WriteLine( "Got CDN auth token for {0} result: {1} (expires {2})", host, cdnAuth.Result, cdnAuth.Expiration );
@ -365,7 +366,7 @@ namespace DepotDownloader
public void CheckAppBetaPassword( uint appid, string password ) public void CheckAppBetaPassword( uint appid, string password )
{ {
bool completed = false; bool completed = false;
Action<SteamApps.CheckAppBetaPasswordCallback> cbMethod = ( appPassword ) => Action<SteamApps.CheckAppBetaPasswordCallback> cbMethod = appPassword =>
{ {
completed = true; completed = true;
@ -385,7 +386,7 @@ namespace DepotDownloader
public PublishedFileDetails GetPublishedFileDetails( uint appId, PublishedFileID pubFile ) public PublishedFileDetails GetPublishedFileDetails( uint appId, PublishedFileID pubFile )
{ {
var pubFileRequest = new CPublishedFile_GetDetails_Request() { appid = appId }; var pubFileRequest = new CPublishedFile_GetDetails_Request { appid = appId };
pubFileRequest.publishedfileids.Add( pubFile ); pubFileRequest.publishedfileids.Add( pubFile );
bool completed = false; bool completed = false;
@ -523,8 +524,6 @@ namespace DepotDownloader
{ {
Console.WriteLine( "Timeout connecting to Steam3." ); Console.WriteLine( "Timeout connecting to Steam3." );
Abort(); Abort();
return;
} }
} }
@ -631,7 +630,8 @@ namespace DepotDownloader
return; return;
} }
else if ( loggedOn.Result == EResult.TryAnotherCM )
if ( loggedOn.Result == EResult.TryAnotherCM )
{ {
Console.Write( "Retrying Steam3 connection (TryAnotherCM)..." ); Console.Write( "Retrying Steam3 connection (TryAnotherCM)..." );
@ -639,14 +639,16 @@ namespace DepotDownloader
return; return;
} }
else if ( loggedOn.Result == EResult.ServiceUnavailable )
if ( loggedOn.Result == EResult.ServiceUnavailable )
{ {
Console.WriteLine( "Unable to login to Steam3: {0}", loggedOn.Result ); Console.WriteLine( "Unable to login to Steam3: {0}", loggedOn.Result );
Abort( false ); Abort( false );
return; return;
} }
else if ( loggedOn.Result != EResult.OK )
if ( loggedOn.Result != EResult.OK )
{ {
Console.WriteLine( "Unable to login to Steam3: {0}", loggedOn.Result ); Console.WriteLine( "Unable to login to Steam3: {0}", loggedOn.Result );
Abort(); Abort();

@ -17,11 +17,13 @@ namespace DepotDownloader
{ {
return "windows"; return "windows";
} }
else if ( RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) )
if ( RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) )
{ {
return "macos"; return "macos";
} }
else if ( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) )
if ( RuntimeInformation.IsOSPlatform( OSPlatform.Linux ) )
{ {
return "linux"; return "linux";
} }

Loading…
Cancel
Save