Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions FileDeduplicator.Test/VerbOutputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,26 @@ public void StatsReportsAFileItCannotHashAsUnreadable()
Assert.Contains("Duplicate groups: 0", output);
}

/// <summary>
/// A file that cannot be hashed is named by its full path, so the failing copy can be found
/// among others sharing its file name.
/// </summary>
[TestMethod]
public void AHashingErrorNamesTheFullPath()
{
// Arrange
using TempTree tree = new();
_ = tree.Write("one/IMG_0001.jpg", "alpha");
AbsoluteFilePath locked = tree.Write("two/IMG_0001.jpg", "beta");
using FileStream holder = new(locked.WeakString, FileMode.Open, FileAccess.ReadWrite, FileShare.None);

// Act
string output = ConsoleCapture.Run(new Stats { PathString = tree.Root.WeakString });

// Assert
Assert.Contains($"Error hashing {locked}:", output);
}

/// <summary>
/// A tree where every file hashes has no unreadable line at all.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion FileDeduplicator/FileHasher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ private static void ReportSkipped(AbsoluteFilePath filePath, Exception ex)
{
lock (ConsoleLock)
{
Console.WriteLine($" Error hashing {filePath.FileName}: {ex.Message}");
// The full path, not the file name: index.js or IMG_0001.jpg can repeat dozens of times in
// one tree, and this line is the only place the failing copy is ever named.
Console.WriteLine($" Error hashing {filePath}: {ex.Message}");
}
}

Expand Down
Loading