mirror of
https://github.com/SteamRE/DepotDownloader.git
synced 2026-10-20 01:46:17 +00:00
Alternate -pubfile implementation using GetDetails
This commit is contained in:
1 parent
079f91167f
commit
8fcfd837b0
2 files changed
+65
-3
No files matched your search
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
@@ -382,11 +383,42 @@ namespace DepotDownloader
|
||||
|
||||
public static async Task DownloadPubfileAsync( uint appId, ulong publishedFileId )
|
||||
{
|
||||
var details = steam3.GetPubfileItemInfo( appId, publishedFileId );
|
||||
var details = steam3.GetPublishedFileDetails( appId, publishedFileId );
|
||||
|
||||
if ( details?.manifest_id > 0 )
|
||||
if ( !string.IsNullOrEmpty( details?.file_url ) )
|
||||
{
|
||||
await DownloadAppAsync( appId, new List<Tuple<uint, ulong>>() { Tuple.Create( appId, details.manifest_id ) }, DEFAULT_BRANCH, null, null, null, false, true );
|
||||
string installDir;
|
||||
if ( !CreateDirectories( details.consumer_appid, (uint)details.revision_change_number, out installDir ) )
|
||||
{
|
||||
Console.WriteLine( "Error: Unable to create install directories!" );
|
||||
return;
|
||||
}
|
||||
|
||||
var stagingDir = Path.Combine( installDir, STAGING_DIR );
|
||||
var fileStagingPath = Path.Combine( stagingDir, details.filename );
|
||||
var fileFinalPath = Path.Combine( installDir, details.filename );
|
||||
|
||||
Directory.CreateDirectory( Path.GetDirectoryName( fileFinalPath ) );
|
||||
Directory.CreateDirectory( Path.GetDirectoryName( fileStagingPath ) );
|
||||
|
||||
using ( var file = File.OpenWrite( fileStagingPath ) )
|
||||
using ( var client = new HttpClient() )
|
||||
{
|
||||
Console.WriteLine( "Downloading {0}", details.filename );
|
||||
var responseStream = await client.GetStreamAsync( details.file_url );
|
||||
await responseStream.CopyToAsync( file );
|
||||
}
|
||||
|
||||
if ( File.Exists( fileFinalPath ) )
|
||||
{
|
||||
File.Delete( fileFinalPath );
|
||||
}
|
||||
|
||||
File.Move( fileStagingPath, fileFinalPath );
|
||||
}
|
||||
else if ( details?.hcontent_file > 0 )
|
||||
{
|
||||
await DownloadAppAsync( appId, new List<Tuple<uint, ulong>>() { Tuple.Create( appId, details.hcontent_file ) }, DEFAULT_BRANCH, null, null, null, false, true );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -443,6 +443,36 @@ namespace DepotDownloader
|
||||
return details;
|
||||
}
|
||||
|
||||
public PublishedFileDetails GetPublishedFileDetails(uint appId, PublishedFileID pubFile)
|
||||
{
|
||||
var pubFileRequest = new CPublishedFile_GetDetails_Request() { appid = appId };
|
||||
pubFileRequest.publishedfileids.Add( pubFile );
|
||||
|
||||
bool completed = false;
|
||||
PublishedFileDetails details = null;
|
||||
|
||||
Action<SteamUnifiedMessages.ServiceMethodResponse> cbMethod = callback =>
|
||||
{
|
||||
completed = true;
|
||||
if (callback.Result == EResult.OK)
|
||||
{
|
||||
var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>();
|
||||
details = response.publishedfiledetails.FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"EResult {(int)callback.Result} ({callback.Result}) while retrieving file details for pubfile {pubFile}.");
|
||||
}
|
||||
};
|
||||
|
||||
WaitUntilCallback(() =>
|
||||
{
|
||||
callbacks.Subscribe(steamPublishedFile.SendMessage(api => api.GetDetails(pubFileRequest)), cbMethod);
|
||||
}, () => { return completed; });
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
void Connect()
|
||||
{
|
||||
bAborted = false;
|
||||
|
||||
Reference in new issue
Block a user