Skip to content

Commit

Permalink
Don't calculate the checksum if the file has not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
omanikhi committed Feb 26, 2025
1 parent 89f4577 commit 2addfd1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions MediaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ public MediaFile(ILogger<MediaContainer> logger,
Logger.LogWarning("Failed To Generate Thumbnails For: {}, Because: {}", FullPath, e.Message);
}

if ((Created || Modified || Checksum is null) && (Size > 0))
if
(
(Created || Modified) &&
(
(Size != Original?.Size) ||
(DateModified.TruncateToSeconds() != Original?.DateModified.TruncateToSeconds()) ||
(DateCreated.TruncateToSeconds() != Original?.DateCreated.TruncateToSeconds())
)
)
{
try
{
Checksum = GetFileChecksum(FullPath);
Checksum = Size > 0 ? GetFileChecksum(FullPath) : null;
}
catch (Exception e)
{
Expand Down

0 comments on commit 2addfd1

Please sign in to comment.