davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.23k stars 196 forks source link

Temporary Directory remains on disk #435

Open BajanMarian opened 2 months ago

BajanMarian commented 2 months ago

Issue Description

When you import govips, a temporary folder is always created, but not always removed.

Replication Steps:

  1. Import govips library
  2. Execute a simple command, such as print(vips.Version) (without invoking vips.Startup()).
  3. 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:

Proposed Solutions:

After reviewing the code, I suggest two potential solutions to address this issue:

  1. 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()).
  2. 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.
tonimelisma commented 2 months ago

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?

BajanMarian commented 2 months ago

Yes.