Implemented deleting files when updating

pull/113/head
NicknineTheEagle 6 years ago
parent 9f092e7801
commit 1afec7199e

@ -596,6 +596,7 @@ namespace DepotDownloader
{
ulong TotalBytesCompressed = 0;
ulong TotalBytesUncompressed = 0;
var previousFiles = new List<ProtoManifest.FileData>();
foreach ( var depot in depots )
{
@ -1004,6 +1005,28 @@ namespace DepotDownloader
await Task.WhenAll( tasks ).ConfigureAwait( false );
// Check for deleted files if updating the depot.
if ( oldProtoManifest != null )
{
var oldfilesAfterExclusions = oldProtoManifest.Files.AsParallel().Where( f => TestIsFileIncluded( f.FileName ) ).ToList();
foreach ( var file in oldfilesAfterExclusions )
{
// Delete it if it's in the old manifest AND not in the new manifest AND not in any of the previous depots.
var newManifestFile = filesAfterExclusions.SingleOrDefault( f => f.FileName == file.FileName );
var previousFile = previousFiles.SingleOrDefault( f => f.FileName == file.FileName );
if ( newManifestFile == null && previousFile == null )
{
string fileFinalPath = Path.Combine( depot.installDir, file.FileName );
File.Delete( fileFinalPath );
Console.WriteLine( "Deleted {0}", fileFinalPath );
}
}
}
// Remember files we processed for later.
previousFiles.AddRange( filesAfterExclusions );
DepotConfigStore.Instance.InstalledManifestIDs[ depot.id ] = depot.manifestId;
DepotConfigStore.Save();

Loading…
Cancel
Save