Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Check font file length Android #13554

Merged
merged 1 commit into from
Nov 17, 2021
Merged
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
3 changes: 2 additions & 1 deletion Xamarin.Forms.Platform.Android/EmbeddedFontLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class EmbeddedFontLoader : IEmbeddedFontLoader
{
var tmpdir = IOPath.GetTempPath();
var filePath = IOPath.Combine(tmpdir, font.FontName);
if (File.Exists(filePath))
var fileInfo = new FileInfo(filePath);
if (fileInfo.Exists && fileInfo.Length == font.ResourceStream.Length)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this could lead to false positives. Better solution is to create a hash, but i think in most cases it will work.
So i'm not sure what the best/fastest way to implement it in xamarin android. Feel free to create another PR to solve this issue.

return (true, filePath);
try
{
Expand Down