From d311b5f59bd19d2a96276ce9105dc5b9573855ea Mon Sep 17 00:00:00 2001 From: NicknineTheEagle Date: Fri, 19 Jun 2020 23:10:07 +0300 Subject: [PATCH] Check if removed files actually exist when updating --- DepotDownloader/ContentDownloader.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index 5d4217f4..bd80ce65 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -1014,13 +1014,19 @@ namespace DepotDownloader { // 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 ); + if ( newManifestFile == null ) + continue; + 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 ); - } + if ( previousFile == null ) + continue; + + string fileFinalPath = Path.Combine( depot.installDir, file.FileName ); + if ( !File.Exists( fileFinalPath ) ) + continue; + + File.Delete( fileFinalPath ); + Console.WriteLine( "Deleted {0}", fileFinalPath ); } }