Skip to content

Commit a7efb56

Browse files
committed
[WIP] Added REVIEW comment regarding info.xml files changes when merging HearThisPack files and added unit test checks for some code changes regarding preservation of modified time (that were actually incorporated as part of HT-359)
1 parent 4e031b3 commit a7efb56

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/HearThis/Communication/WindowsLink.cs

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public bool TryListFiles(string androidPath, out string list)
6060
foreach (var file in Directory.EnumerateFiles(path, "*.*"))
6161
{
6262
var filename = Path.GetFileName(file);
63+
// REVIEW: We need to consider whether/when changes to info.xml files
64+
// might need to be regarded as significant for determining which
65+
// version to use in merge, since the "Check For Problems" view makes
66+
// it more likely for the info file to change without any clips being
67+
// modified.
6368
if (filename == "info.xml")
6469
continue;
6570
sb.Append(filename);

src/HearThis/Script/ChapterInfo.cs

+3
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ private void Save(string filePath, bool preserveModifiedTime = false)
408408
throw new Exception($"Unable to save {GetType().Name} file: " + filePath, error);
409409

410410
if (preserveModifiedTime)
411+
{
411412
finfo.LastWriteTimeUtc = modified;
413+
finfo.Attributes |= FileAttributes.Archive;
414+
}
412415
}
413416

414417
public string ToXmlString()

src/HearThisTests/ClipRepositoryTests.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1554,13 +1554,14 @@ public void ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate_AllFilesModifiedBefo
15541554
const int kTestChapter = 1;
15551555

15561556
var chapterFolder = ClipRepository.GetChapterFolder(testProject, kTestBook, kTestChapter);
1557-
ChapterRecordingInfoBase info;
1557+
TestChapterInfo info;
15581558
if (includeClip0)
15591559
info = new TestChapterInfo(1, 2, 3, 8); // Intentionally omitted 4, just to make sure the logic is okay with having one missing.
15601560
else
15611561
info = new TestChapterInfo(2, 3, 8); // Intentionally omitted 4, just to make sure the logic is okay with having one missing.
15621562
info.RecordingInfo[1].SkippedChanged += sender => { }; // code requires us to have a handler before we can set it.
15631563
info.RecordingInfo[1].Skipped = true;
1564+
info.ExpectedPreserveModifiedTime = true;
15641565

15651566
try
15661567
{
@@ -1575,13 +1576,15 @@ public void ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate_AllFilesModifiedBefo
15751576
// SUT
15761577
Assert.IsTrue(ClipRepository.ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate(
15771578
testProject, kTestBook, kTestChapter, 1, DateTime.UtcNow, () => info));
1579+
15781580
Assert.AreEqual(includeClip0 ? 5 : 4, Directory.GetFiles(chapterFolder).Length);
15791581
Assert.That(File.Exists(Path.Combine(chapterFolder, "8.wav")));
15801582
Assert.That(File.Exists(Path.Combine(chapterFolder, "4.wav")));
15811583
Assert.That(File.Exists(Path.Combine(chapterFolder, "3.skip")));
15821584
Assert.That(File.Exists(Path.Combine(chapterFolder, "2.wav")));
15831585
Assert.IsFalse(File.Exists(Path.Combine(chapterFolder, "1.wav")));
15841586
Assert.AreEqual(includeClip0, File.Exists(file0));
1587+
Assert.AreEqual(1, info.SaveCallCount);
15851588

15861589
int i = 0;
15871590
if (includeClip0)
@@ -1889,6 +1892,7 @@ private class TestChapterInfo : ChapterRecordingInfoBase
18891892
private readonly List<ScriptLine> _recordings;
18901893

18911894
public int SaveCallCount { get; private set; }
1895+
public bool ExpectedPreserveModifiedTime { get; set; }
18921896

18931897
public TestChapterInfo(params int[] scriptLineNumbers)
18941898
{
@@ -1905,6 +1909,7 @@ public override void OnScriptBlockRecorded(ScriptLine selectedScriptBlock)
19051909

19061910
public override void Save(bool preserveModifiedTime = false)
19071911
{
1912+
Assert.AreEqual(ExpectedPreserveModifiedTime, preserveModifiedTime);
19081913
SaveCallCount++;
19091914
}
19101915
}

src/HearThisTests/ScriptProviderBaseTests.cs

+1
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ public override void OnScriptBlockRecorded(ScriptLine scriptBlock)
802802

803803
public override void Save(bool preserveModifiedTime = false)
804804
{
805+
Assert.IsTrue(preserveModifiedTime);
805806
SaveCallCount++;
806807
}
807808
}

0 commit comments

Comments
 (0)