From 89cdae3ef3b2c5084e40392bf728e36b4d2b8a56 Mon Sep 17 00:00:00 2001 From: Michael Busby Date: Mon, 6 Feb 2012 19:06:09 -0600 Subject: [PATCH] DepotDownloader: Unlink existing file if the size/checksum don't match (for compatibility with file links) --- DepotDownloader/ContentDownloader.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DepotDownloader/ContentDownloader.cs b/DepotDownloader/ContentDownloader.cs index d31dc8ad..eeeb0098 100644 --- a/DepotDownloader/ContentDownloader.cs +++ b/DepotDownloader/ContentDownloader.cs @@ -710,14 +710,18 @@ namespace DepotDownloader Console.WriteLine("{0,6:#00.00}%\t{1}", perc, downloadPath); FileInfo fi = new FileInfo( downloadPath ); - if (fi.Exists && fi.Length == dirEntry.SizeOrCount) + if (fi.Exists) { // Similar file, let's check checksums - if(Util.ValidateFileChecksums(fi, checksums.GetFileChecksums(dirEntry.FileID))) + if(fi.Length == dirEntry.SizeOrCount && + Util.ValidateFileChecksums(fi, checksums.GetFileChecksums(dirEntry.FileID))) { // checksums OK continue; } + // Unlink the current file before we download a new one. + // This will keep symbolic/hard link targets from being overwritten. + fi.Delete(); } var file = session.DownloadFile( dirEntry, ContentServerClient.StorageSession.DownloadPriority.High, cryptKey );