示例#1
0
        /// <summary>
        /// If there are any stale downloads, freshen them
        /// </summary>
        /// <returns>true if any files are shown to be stale and thus worthy of a retry of the test that uses them</returns>
        public bool FreshenTestDataDownloads()
        {
            if (DictZipFileIsKnownCurrent == null || DictZipFileIsKnownCurrent.All(kvp => kvp.Value))
            {
                return(false);
            }
            var knownStale = false;

            foreach (var zipPath in DictZipFileIsKnownCurrent.Where(kvp => !kvp.Value).Select(kvp => kvp.Key).ToArray())
            {
                var targetFolder    = GetTargetZipFilePath(zipPath, out var zipFilePath);
                var zipFilePathTest = zipFilePath + @".new";
                DownloadZipFile(targetFolder, zipPath, zipFilePathTest);
                if (!FileEx.AreIdenticalFiles(zipFilePath, zipFilePathTest))
                {
                    knownStale = true;
                    File.Delete(zipFilePath);
                    File.Move(zipFilePathTest, zipFilePath);
                }
                else
                {
                    File.Delete(zipFilePathTest);
                }
                DictZipFileIsKnownCurrent[zipPath] = true;
            }

            return(knownStale);
        }