diff --git a/src/HearThis/Communication/WindowsLink.cs b/src/HearThis/Communication/WindowsLink.cs index 60dae1ee..e16839c2 100644 --- a/src/HearThis/Communication/WindowsLink.cs +++ b/src/HearThis/Communication/WindowsLink.cs @@ -60,6 +60,11 @@ public bool TryListFiles(string androidPath, out string list) foreach (var file in Directory.EnumerateFiles(path, "*.*")) { var filename = Path.GetFileName(file); + // REVIEW: We need to consider whether/when changes to info.xml files + // might need to be regarded as significant for determining which + // version to use in merge, since the "Check For Problems" view makes + // it more likely for the info file to change without any clips being + // modified. if (filename == "info.xml") continue; sb.Append(filename); diff --git a/src/HearThis/Script/ChapterInfo.cs b/src/HearThis/Script/ChapterInfo.cs index 3a8a013b..a5fd8c6e 100644 --- a/src/HearThis/Script/ChapterInfo.cs +++ b/src/HearThis/Script/ChapterInfo.cs @@ -435,7 +435,10 @@ private void Save(string filePath, bool preserveModifiedTime = false) throw new Exception($"Unable to save {GetType().Name} file: " + filePath, error); if (preserveModifiedTime) + { finfo.LastWriteTimeUtc = modified; + finfo.Attributes |= FileAttributes.Archive; + } } public string ToXmlString() diff --git a/src/HearThisTests/ClipRepositoryTests.cs b/src/HearThisTests/ClipRepositoryTests.cs index 8cdc1289..7749f4e0 100644 --- a/src/HearThisTests/ClipRepositoryTests.cs +++ b/src/HearThisTests/ClipRepositoryTests.cs @@ -1682,13 +1682,14 @@ public void ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate_AllFilesModifiedBefo const int kTestChapter = 1; var chapterFolder = ClipRepository.GetChapterFolder(testProject, kTestBook, kTestChapter); - ChapterRecordingInfoBase info; + TestChapterInfo info; if (includeClip0) info = new TestChapterInfo(1, 2, 3, 8); // Intentionally omitted 4, just to make sure the logic is okay with having one missing. else info = new TestChapterInfo(2, 3, 8); // Intentionally omitted 4, just to make sure the logic is okay with having one missing. info.RecordingInfo[1].SkippedChanged += sender => { }; // code requires us to have a handler before we can set it. info.RecordingInfo[1].Skipped = true; + info.ExpectedPreserveModifiedTime = true; try { @@ -1703,13 +1704,14 @@ public void ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate_AllFilesModifiedBefo // SUT Assert.That(ClipRepository.ShiftClipsAtOrAfterBlockIfAllClipsAreBeforeDate( testProject, kTestBook, kTestChapter, 1, DateTime.UtcNow, () => info), Is.True); - Assert.That(Directory.GetFiles(chapterFolder).Length, Is.EqualTo(includeClip0 ? 5 : 4)); + Assert.That(Path.Combine(chapterFolder, "8.wav"), Does.Exist); Assert.That(Path.Combine(chapterFolder, "4.wav"), Does.Exist); Assert.That(Path.Combine(chapterFolder, "3.skip"), Does.Exist); Assert.That(Path.Combine(chapterFolder, "2.wav"), Does.Exist); Assert.That(Path.Combine(chapterFolder, "1.wav"), Does.Not.Exist); Assert.That(File.Exists(file0), Is.EqualTo(includeClip0)); + Assert.That(info.SaveCallCount, Is.EqualTo(1)); int i = 0; if (includeClip0) @@ -2193,6 +2195,7 @@ private class TestChapterInfo : ChapterRecordingInfoBase private readonly List _recordings; public int SaveCallCount { get; private set; } + public bool ExpectedPreserveModifiedTime { get; set; } public TestChapterInfo(params int[] scriptLineNumbers) { @@ -2215,6 +2218,7 @@ public override void OnScriptBlockRecorded(ScriptLine scriptBlock, public override void Save(bool preserveModifiedTime = false) { + Assert.That(preserveModifiedTime, Is.EqualTo(ExpectedPreserveModifiedTime)); SaveCallCount++; } } diff --git a/src/HearThisTests/ScriptProviderBaseTests.cs b/src/HearThisTests/ScriptProviderBaseTests.cs index 0d24f449..90b9ad98 100644 --- a/src/HearThisTests/ScriptProviderBaseTests.cs +++ b/src/HearThisTests/ScriptProviderBaseTests.cs @@ -807,6 +807,7 @@ public override void OnScriptBlockRecorded(ScriptLine scriptBlock, public override void Save(bool preserveModifiedTime = false) { + Assert.That(preserveModifiedTime, Is.True); SaveCallCount++; } }