Skip to content

Commit

Permalink
Add ChorusStorage (the bundle cache) as an Excluded folder (LT-21408)
Browse files Browse the repository at this point in the history
* The files were still checked by the LargeFileFilter even though
  they were never included in the repo causing unneeded warnings
  • Loading branch information
jasonleenaylor committed Aug 3, 2023
1 parent 80bee2f commit 271b640
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/LibChorus/sync/ProjectFolderConfiguration.cs
Original file line number Diff line number Diff line change
@@ -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<string> _includePatterns = new List<string>(new[] { "**.ChorusNotes" });
private readonly List<string> _excludePatterns = new List<string>(new[] { BareFolderReadmeFileName /* for bare folder readme file */, "**.NewChorusNotes" });
private readonly List<string> _excludePatterns = new List<string>(new[] { BareFolderReadmeFileName /* for bare folder readme file */, "**.NewChorusNotes", ChorusStorageFolderContent });
private string _folderPath;

public ProjectFolderConfiguration(string folderPath)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
25 changes: 25 additions & 0 deletions src/LibChorusTests/sync/LargeFileFilterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 271b640

Please sign in to comment.