4

Recently I have noticed that unpublished binary files are still available in DXA 2.0 web application. Checked in database, they were unpublished properly. However still exist in BinaryData folder.

Do you have the same behavior? Am I missing some configuration?

  • Try setting the DXA log level to DEBUG an see in the DXA log – Anand NS Aug 6 at 8:25
  • can you check if that binary file is used in different place , may be the binary file still have reference. – Anand NS Aug 6 at 9:38
  • yes, sometimes this issue arises may be because of not having proper read write delete access to the drive, please check if these access are enabled. But i guess once you will restart the server all the files will load fresh after accessing the page. – SDLBeginner Aug 8 at 7:44
1

It seems you are right that cached Binary files are no longer automatically removed when the Binary is unpublished.

The cleanup code was removed in DXA 1.8: https://github.com/sdl/dxa-web-application-dotnet/commit/1a78d03003e614745fba9714eaf6b4c8a19066a4#diff-dc665a329e7453c1f17f6ce4e9e95524

  • Right, but the main issue is that binary file is still rendered by web app when file is unpublished. – Stan Kroshchenko Aug 14 at 21:13
3

Finally found what was the root cause. There is an issue with BinaryFileManager.IsCached method. It does not account if file was unpublished.

When you call IsCached method it will get lastPublishedDate, however lastPublishedDate for unpublished binary file is DateTime.MinValue. Based on my testing IsCached method does not handle situation when lastPublishedData is DateTime.MinValue.

To fix it I added next code:

if (lastPublishedDate == DateTime.MinValue)
{
    //Last published data is minValue, so file has been unpublished. 
    Log.Debug(
        "Binary at path '{0}' has been unpublished",
        localFilePath);
    return false;
}

One more issue that I noticed in that method is that localization.LastRefresh and lastPublishedDate are using different time zones.

Also added next line to fix time zone difference:

lastPublishedDate = lastPublishedDate.ToLocalTime();

Hopefully it will be fixed in the next DXA release

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.