Change directory structure. Use value for args.

pull/583/head
Alstruit 10 months ago
parent 44b9a2c913
commit dab93017d3
No known key found for this signature in database
GPG Key ID: 4F57E6793C946CEC

@ -56,11 +56,45 @@ namespace DepotDownloader
{
Directory.CreateDirectory(DEFAULT_DOWNLOAD_DIR);
var depotPath = Path.Combine(DEFAULT_DOWNLOAD_DIR, depotId.ToString());
Directory.CreateDirectory(depotPath);
// Check if we should use publishedFileId or ugcId directories
if (Config.UsePubOrUgcDirectories)
{
// We need an appId to structure this properly.
// The appId can be retrieved from Config.AppId if you choose to store it there,
// or we can rely on it being set previously.
// If needed, add a field in Config for the current appId being processed.
// Assume we have a Config.AppId that stores the current app ID.
var appId = Config.AppId;
var appPath = Path.Combine(DEFAULT_DOWNLOAD_DIR, appId.ToString());
Directory.CreateDirectory(appPath);
if (Config.PublishedFileId != 0)
{
var pubPath = Path.Combine(appPath, Config.PublishedFileId.ToString());
Directory.CreateDirectory(pubPath);
// Use depotVersion as the final directory level
installDir = Path.Combine(pubPath, depotVersion.ToString());
Directory.CreateDirectory(installDir);
}
else if (Config.UgcId != 0)
{
var ugcPath = Path.Combine(appPath, Config.UgcId.ToString());
Directory.CreateDirectory(ugcPath);
// Use depotVersion as the final directory level
installDir = Path.Combine(ugcPath, depotVersion.ToString());
Directory.CreateDirectory(installDir);
}
}
else
{
var depotPath = Path.Combine(DEFAULT_DOWNLOAD_DIR, depotId.ToString());
Directory.CreateDirectory(depotPath);
installDir = Path.Combine(depotPath, depotVersion.ToString());
Directory.CreateDirectory(installDir);
installDir = Path.Combine(depotPath, depotVersion.ToString());
Directory.CreateDirectory(installDir);
}
Directory.CreateDirectory(Path.Combine(installDir, CONFIG_DIR));
Directory.CreateDirectory(Path.Combine(installDir, STAGING_DIR));
@ -68,7 +102,6 @@ namespace DepotDownloader
else
{
Directory.CreateDirectory(Config.InstallDirectory);
installDir = Config.InstallDirectory;
Directory.CreateDirectory(Path.Combine(installDir, CONFIG_DIR));
@ -84,6 +117,7 @@ namespace DepotDownloader
}
static bool TestIsFileIncluded(string filename)
{
if (!Config.UsingFileList)
@ -350,6 +384,11 @@ namespace DepotDownloader
{
var details = await steam3.GetPublishedFileDetails(appId, publishedFileId);
// Set the current appId and publishedFileId in the config
Config.AppId = appId; // Make sure AppId is a field in Config as well
Config.PublishedFileId = publishedFileId;
Config.UgcId = 0; // Reset ugcId
if (!string.IsNullOrEmpty(details?.file_url))
{
await DownloadWebFile(appId, details.filename, details.file_url);
@ -362,12 +401,21 @@ namespace DepotDownloader
{
Console.WriteLine("Unable to locate manifest ID for published file {0}", publishedFileId);
}
// Reset after download if you prefer a clean slate
Config.PublishedFileId = 0;
}
public static async Task DownloadUGCAsync(uint appId, ulong ugcId)
{
SteamCloud.UGCDetailsCallback details = null;
// Set the current appId and ugcId in the config
Config.AppId = appId;
Config.UgcId = ugcId;
Config.PublishedFileId = 0; // Reset publishedFileId
if (steam3.steamUser.SteamID.AccountType != EAccountType.AnonUser)
{
details = await steam3.GetUGCDetails(ugcId);
@ -385,11 +433,15 @@ namespace DepotDownloader
{
await DownloadAppAsync(appId, [(appId, ugcId)], DEFAULT_BRANCH, null, null, null, false, true);
}
// Reset after download if you prefer a clean slate
Config.UgcId = 0;
}
private static async Task DownloadWebFile(uint appId, string fileName, string url)
{
if (!CreateDirectories( 0, 0, out var installDir))
if (!CreateDirectories(0, 0, out var installDir))
{
Console.WriteLine("Error: Unable to create install directories!");
return;
@ -618,7 +670,7 @@ namespace DepotDownloader
return null;
}
if (!CreateDirectories( depotId, manifestId, out var installDir))
if (!CreateDirectories(depotId, manifestId, out var installDir))
{
Console.WriteLine("Error: Unable to create install directories!");
return null;

@ -32,5 +32,12 @@ namespace DepotDownloader
public uint? LoginID { get; set; }
public bool UseQrCode { get; set; }
public ulong PublishedFileId { get; set; } = 0;
public ulong UgcId { get; set; } = 0;
public uint AppId { get; set; } = 0;
// Helper property to determine if we're using pubfile/ugc directories
public bool UsePubOrUgcDirectories => (PublishedFileId != 0 || UgcId != 0);
}
}

Loading…
Cancel
Save