yandex-qatools / postgresql-embedded

Embedded PostgreSQL Server
Other
493 stars 90 forks source link

Default temp directory not deleted on exit #113

Open jeremiehuchet opened 6 years ago

jeremiehuchet commented 6 years ago

The default directory where the postgres binary is extracted is not deleted on exit despite of the following line: https://github.com/yandex-qatools/postgresql-embedded/blob/a47e90f5da76a8bc21bb4ce946e8706373f451b6/src/main/java/ru/yandex/qatools/embed/postgresql/ext/SubdirTempDir.java#L27

File#deleteOnExit() documentation refers to File#delete() and the latter says:

Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a directory, then the directory must be empty in order to be deleted

I expect the temp dir and its content to be deleted on exit. Am I wrong?

jeremiehuchet commented 6 years ago

Tip How to use your custom version of PostgreSQL acts as a workaround.

smecsia commented 6 years ago

Hi @jeremiehuchet . Looks like it is a bug in EmbeddedPostgres class, which is removing data only. Another issue is that by default it uses CachedPostgresArtifactStore which does not remove artifacts intentionally (to optimize the extracted artifacts usage).

I'll think about the proper way of solving this issue. You can now remove the directory manually as a workaround.