WeasyPrint icon indicating copy to clipboard operation
WeasyPrint copied to clipboard

Temporary directory does not get removed

Open braggpeaks opened this issue 1 year ago • 9 comments

weasyprint apparently creates a temporary directory but does not remove the directory afterwards.

Windows folder location: C:\Users\user.name\AppData\Local\Temp Subfolder naming example: weasyprint-0qjsm58z

The folders are empty but I believe they should be removed to not leave unnecessary folders (I currently have 8000 of these weasyprint-* folders, don't ask 😂).

braggpeaks avatar Mar 08 '24 12:03 braggpeaks

Hi!

The folders are supposed to be removed here, but:

  • It is not guaranteed that __del__() methods are called for objects that still exist when the interpreter exits (quoting the Python documentation), and
  • Windows likes to keep references to folders/files even when they’re not used anymore, preventing them to be deleted.

The "real" solution would be to only use data in memory (fonts are not that big). It should be possible to keep config files in memory thanks to FcConfigParseAndLoadFromMemory but there’s nothing to replace FcConfigAppFontAddFile.

If someone finds a better solution, I’ll be happy to try!

liZe avatar Mar 08 '24 20:03 liZe