govips
govips copied to clipboard
Temporary Directory remains on disk
Issue Description
When you import govips, a temporary folder is always created, but not always removed.
Replication Steps:
- Import govips library
- Execute a simple command, such as print(vips.Version) (without invoking vips.Startup()).
- Allow the program to terminate.
In this scenario, the temporary directory persists on disk, which it should not. The only way to ensure its removal currently is to explicitly call vips.Startup() and then defer vips.Shutdown()
Real-world Scenario:
- Package A imports govips because it uses some govips functions
- Package main imports Package A
- Pacakge main only uses some constants from Package A (not related to govips)
- After performing its tasks, the main package completes execution, but the temporary govips folder remains on disk
Proposed Solutions:
After reviewing the code, I suggest two potential solutions to address this issue:
- Create the Temporary Directory During vips.Startup(): This would ensure that the temporary folder is only created when vips.Startup() is explicitly called. It is important to note that in the current implementation, the folder is deleted only if the ### running variable is set to TRUE (as managed in vips.Shutdown()).
- Expose a Method to Delete the Temporary Folder: Provide a method within the govips library that can be called to remove the temporary directory explicitly. This would allow users to clean up the directory without relying on vips.Startup() and vips.Shutdown() if they are not using the full capabilities of the library.
Thank you!! This is a great bug report. I agree that management of the temporary Director should be more explicit. I think the first solution would make more sense.
Would you have interest in developing a PR?
Yes.