gus33000 / UUPMediaCreator

An utility to create Windows Media files (.ISO, .WIM, .VHD) from Unified Update Platform files
MIT License
778 stars 65 forks source link

UUPMediaConverter doesn't cleanup after itself after SIGINT #182

Open kwvg opened 11 months ago

kwvg commented 11 months ago

Description

UUPMediaConverter stores its in-progress files in %Temp% by default (configurable with temp-path). If the program is run and then sent a SIGINT signal (say, by using Ctrl+C), the application immediately exits without cleaning after itself. This results in multi-gigabyte directories that fill up temp-path.

If this is repeated enough times (twice in my case), temp-path will exhaust the partition's space, preventing the program from proceeding any further.

Possible solutions

SIGINT gives the program a chance to shut down the program gracefully, so perhaps in a shutdown sequence, the temporary files are deleted unless a flag is set that retains them (say, --retain-temp-files). This will not account for SIGKILL terminations, as by nature, they don't give the process a chance to do anything.

So, additionally, perhaps the directory in temp-path can be ear-tagged with a GUID generated at runtime and a retention flag. If the flag is present, leave the examined directory alone, create a new directory and proceed. If the flag is absent, the GUID wouldn't match and the directory can be deleted.

Steps to reproduce

Additional Notes