From 271b640d6ba47b0b6d6dc2bed049d10934f7ee02 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Wed, 2 Aug 2023 15:06:24 -0700 Subject: [PATCH] Add ChorusStorage (the bundle cache) as an Excluded folder (LT-21408) * The files were still checked by the LargeFileFilter even though they were never included in the repo causing unneeded warnings --- .../sync/ProjectFolderConfiguration.cs | 6 ++++- .../LargeFileIntegrationTestService.cs | 1 + .../sync/LargeFileFilterTests.cs | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/LibChorus/sync/ProjectFolderConfiguration.cs b/src/LibChorus/sync/ProjectFolderConfiguration.cs index 7a9fdf345..afdee0b1e 100644 --- a/src/LibChorus/sync/ProjectFolderConfiguration.cs +++ b/src/LibChorus/sync/ProjectFolderConfiguration.cs @@ -1,12 +1,14 @@ using System.Collections.Generic; +using System.IO; namespace Chorus.sync { public class ProjectFolderConfiguration { public const string BareFolderReadmeFileName = "~~*.txt"; + public static string ChorusStorageFolderContent = Path.Combine("Chorus", "ChorusStorage", "**.*"); private readonly List _includePatterns = new List(new[] { "**.ChorusNotes" }); - private readonly List _excludePatterns = new List(new[] { BareFolderReadmeFileName /* for bare folder readme file */, "**.NewChorusNotes" }); + private readonly List _excludePatterns = new List(new[] { BareFolderReadmeFileName /* for bare folder readme file */, "**.NewChorusNotes", ChorusStorageFolderContent }); private string _folderPath; public ProjectFolderConfiguration(string folderPath) @@ -59,6 +61,8 @@ public static void EnsureCommonPatternsArePresent(ProjectFolderConfiguration pro projectFolderConfiguration._excludePatterns.Add(BareFolderReadmeFileName); if (!projectFolderConfiguration._excludePatterns.Contains("**.NewChorusNotes")) projectFolderConfiguration._excludePatterns.Add("**.NewChorusNotes"); + if (!projectFolderConfiguration._excludePatterns.Contains(ChorusStorageFolderContent)) + projectFolderConfiguration._excludePatterns.Add(ChorusStorageFolderContent); } public static void AddExcludedVideoExtensions(ProjectFolderConfiguration projectFolderConfiguration) diff --git a/src/LibChorusTests/FileHandlers/LargeFileIntegrationTestService.cs b/src/LibChorusTests/FileHandlers/LargeFileIntegrationTestService.cs index 414e0bc75..0448c435a 100644 --- a/src/LibChorusTests/FileHandlers/LargeFileIntegrationTestService.cs +++ b/src/LibChorusTests/FileHandlers/LargeFileIntegrationTestService.cs @@ -73,6 +73,7 @@ public static void TestThatALargeFileIsNotInRepository(string extension) Assert.That(syncResults.Succeeded, Is.True); projectFolderConfiguration.ExcludePatterns.Remove(ProjectFolderConfiguration.BareFolderReadmeFileName); + projectFolderConfiguration.ExcludePatterns.Remove(ProjectFolderConfiguration.ChorusStorageFolderContent); Assert.That(projectFolderConfiguration.ExcludePatterns.Count, Is.EqualTo(2)); Assert.That(projectFolderConfiguration.ExcludePatterns[0], Does.Contain(whopperFileName)); diff --git a/src/LibChorusTests/sync/LargeFileFilterTests.cs b/src/LibChorusTests/sync/LargeFileFilterTests.cs index f01abe5dc..517ffad67 100644 --- a/src/LibChorusTests/sync/LargeFileFilterTests.cs +++ b/src/LibChorusTests/sync/LargeFileFilterTests.cs @@ -242,6 +242,31 @@ public void LongWavFileIsFilteredOutAndNotInRepo() } } + [Test] + public void BundleInCacheDoesNotWarn() + { + using (var bob = new RepositorySetup("bob")) + { + var megabyteLongData = "super-duper-long" + Environment.NewLine; + while (megabyteLongData.Length < LargeFileFilter.Megabyte * 10) + megabyteLongData += megabyteLongData; + var chorusStoragePath = ProjectFolderConfiguration.ChorusStorageFolderContent.Replace("**.*", ""); + string fileName = Path.Combine(chorusStoragePath, "test.bundle"); + Directory.CreateDirectory(Path.Combine(bob.ProjectFolder.Path, chorusStoragePath)); + bob.ChangeFile(fileName, megabyteLongData); + var config = bob.ProjectFolderConfig; + + var result = LargeFileFilter.FilterFiles( + bob.Repository, + config, + ChorusFileTypeHandlerCollection.CreateWithInstalledHandlers()); + Assert.That(result, Is.Null.Or.Empty); + Assert.That(config.ExcludePatterns, Contains.Item(ProjectFolderConfiguration.ChorusStorageFolderContent)); + bob.Repository.AddAndCheckinFiles(config.IncludePatterns, config.ExcludePatterns, "Some commit"); + bob.AssertFileDoesNotExistInRepository("test.bundle"); + } + } + [Test] public void NormallyExcludedFwdataFileIsNotAddedByLargeFileFilter() {