From b3fb009a4181b9b5f4f15a8edc8b577114fd0adc Mon Sep 17 00:00:00 2001 From: NicknineTheEagle Date: Sun, 4 Apr 2021 09:14:01 +0300 Subject: [PATCH] Updated manifest-to-text conversion to imitate Steam format --- DepotDownloader/ContentDownloader.cs | 59 +++++++++++++++++++++------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index cbf38b97..962163ae 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -907,21 +907,7 @@ namespace DepotDownloader if (Config.DownloadManifestOnly) { - StringBuilder manifestBuilder = new StringBuilder(); - string txtManifest = Path.Combine(depot.installDir, string.Format("manifest_{0}_{1}.txt", depot.id, depot.manifestId)); - manifestBuilder.Append(string.Format("{0}\n\n", newProtoManifest.CreationTime)); - - foreach (var file in newProtoManifest.Files) - { - if (file.Flags.HasFlag(EDepotFileFlag.Directory)) - continue; - - manifestBuilder.Append(string.Format("{0}\n", file.FileName)); - manifestBuilder.Append(string.Format("\t{0}\n", file.TotalSize)); - manifestBuilder.Append(string.Format("\t{0}\n", BitConverter.ToString(file.FileHash).Replace("-", ""))); - } - - File.WriteAllText(txtManifest, manifestBuilder.ToString()); + DumpManifestToTextFile(depot, newProtoManifest); return null; } @@ -1295,5 +1281,48 @@ namespace DepotDownloader } } + + static void DumpManifestToTextFile( DepotDownloadInfo depot, ProtoManifest manifest ) + { + var txtManifest = Path.Combine( depot.installDir, $"manifest_{depot.id}_{depot.manifestId}.txt" ); + + using ( var sw = new StreamWriter( txtManifest ) ) + { + sw.WriteLine( $"Content Manifest for Depot {depot.id}" ); + sw.WriteLine(); + sw.WriteLine( $"Manifest ID / date : {depot.manifestId} / {manifest.CreationTime}" ); + + int numFiles = 0, numChunks = 0; + ulong uncompressedSize = 0, compressedSize = 0; + + foreach ( var file in manifest.Files ) + { + if ( file.Flags.HasFlag( EDepotFileFlag.Directory ) ) + continue; + + numFiles++; + numChunks += file.Chunks.Count; + + foreach ( var chunk in file.Chunks ) + { + uncompressedSize += chunk.UncompressedLength; + compressedSize += chunk.CompressedLength; + } + } + + sw.WriteLine( $"Total number of files : {numFiles}" ); + sw.WriteLine( $"Total number of chunks : {numChunks}" ); + sw.WriteLine( $"Total bytes on disk : {uncompressedSize}" ); + sw.WriteLine( $"Total bytes compressed : {compressedSize}" ); + sw.WriteLine(); + sw.WriteLine( " Size Chunks File SHA Flags Name" ); + + foreach ( var file in manifest.Files ) + { + var sha1Hash = BitConverter.ToString( file.FileHash ).Replace( "-", "" ); + sw.WriteLine( $"{file.TotalSize,14} {file.Chunks.Count,6} {sha1Hash} {file.Flags,5:D} {file.FileName}" ); + } + } + } } }