onizet / html2openxml

Html2OpenXml is a small .Net library that convert simple or advanced HTML to plain OpenXml components. This program has started in 2009, initially to convert user's comments from SharePoint to Word.
MIT License
297 stars 106 forks source link

ImagePrefetcher doesn't actually cache the images #118

Closed cneuwirt closed 6 months ago

cneuwirt commented 2 years ago

The ImagePrefetcher.cs has the following method

public HtmlImageInfo Download(string imageUri)
{
         if (prefetchedImages.Contains(imageUri))
             return prefetchedImages[imageUri];

         if (DataUri.IsWellFormed(imageUri)) // data inline, encoded in base64
         {
             return ReadDataUri(imageUri);
         }

         return DownloadRemoteImage(imageUri);
}

As you can see, it checks the cache for existing imageUri, but never adds to it so it will always fetch images and possibly create duplicate image parts.

onizet commented 6 months ago

Indeed, stupid distraction error! Thanks for reporting, published in v2.4