-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big speed improvements for some cases:
- Store all manifests separately, including excluded file, rather than only list of last-downloaded. - Don't redownload manifests we have. - Don't connect to content servers if no manifest to download and no chunks needed. - Don't connect to content servers until needing chunks if already having manifest.
- Loading branch information
Showing
7 changed files
with
238 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using ProtoBuf; | ||
using System.IO; | ||
using System.IO.Compression; | ||
|
||
namespace DepotDownloader | ||
{ | ||
[ProtoContract] | ||
class ConfigStore | ||
{ | ||
[ProtoMember(1)] | ||
public Dictionary<uint, ulong> LastManifests { get; private set; } | ||
|
||
[ProtoMember(3, IsRequired=false)] | ||
public Dictionary<string, byte[]> SentryData { get; private set; } | ||
|
||
string FileName = null; | ||
|
||
ConfigStore() | ||
{ | ||
LastManifests = new Dictionary<uint, ulong>(); | ||
SentryData = new Dictionary<string, byte[]>(); | ||
} | ||
|
||
static bool Loaded | ||
{ | ||
get { return TheConfig != null; } | ||
} | ||
|
||
public static ConfigStore TheConfig = null; | ||
|
||
public static void LoadFromFile(string filename) | ||
{ | ||
if (Loaded) | ||
throw new Exception("Config already loaded"); | ||
|
||
if (File.Exists(filename)) | ||
{ | ||
using (FileStream fs = File.Open(filename, FileMode.Open)) | ||
using (DeflateStream ds = new DeflateStream(fs, CompressionMode.Decompress)) | ||
TheConfig = ProtoBuf.Serializer.Deserialize<ConfigStore>(ds); | ||
} | ||
else | ||
{ | ||
TheConfig = new ConfigStore(); | ||
} | ||
|
||
TheConfig.FileName = filename; | ||
} | ||
|
||
public static void Save() | ||
{ | ||
if (!Loaded) | ||
throw new Exception("Saved config before loading"); | ||
|
||
using (FileStream fs = File.Open(TheConfig.FileName, FileMode.Create)) | ||
using (DeflateStream ds = new DeflateStream(fs, CompressionMode.Compress)) | ||
ProtoBuf.Serializer.Serialize<ConfigStore>(ds, TheConfig); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.