Temporary files not cleaned up on exit #35

Open
opened 2021-04-10 11:25:20 +00:00 by Ghost · 0 comments

Hello, I've noticed AV-98 does not delete all its temporary files upon exit. After some debugging, I believe this happens for temporary files created by _fetch_over_network only when cache option is disabled: https://tildegit.org/solderpunk/AV-98/src/branch/master/av98.py#L523-L531

From what I understood, a new temporary files is created on each call of _fetch_over_network and the filename is assigned to self.tmp_filename and, if cache option is enabled, is added to self.cache. If cache option is not enabled, self.tmp_filename is overwritten each time a new URL is visited, and references to any intermediate temporary files are lost and thus not cleaned up upon exit in do_quit.

Instead of keeping track/manually deleting all the temporary files, perhaps one solution could be to utilize tempfile.TemporaryDirectory to store all AV-98 temporary files in one temporary directory that is deleted (including its content) when the object is destroyed/context manager is exited, or manually with .cleanup().

Hello, I've noticed AV-98 does not delete all its temporary files upon exit. After some debugging, I believe this happens for temporary files created by `_fetch_over_network` only when `cache` option is disabled: https://tildegit.org/solderpunk/AV-98/src/branch/master/av98.py#L523-L531 From what I understood, a new temporary files is created on each call of `_fetch_over_network` and the filename is assigned to `self.tmp_filename` and, if `cache` option is enabled, is added to `self.cache`. If `cache` option is not enabled, `self.tmp_filename` is overwritten each time a new URL is visited, and references to any intermediate temporary files are lost and thus not cleaned up upon exit in `do_quit`. Instead of keeping track/manually deleting all the temporary files, perhaps one solution could be to utilize [`tempfile.TemporaryDirectory`](https://docs.python.org/3/library/tempfile.html#tempfile.TemporaryDirectory) to store all AV-98 temporary files in one temporary directory that is deleted (including its content) when the object is destroyed/context manager is exited, or manually with `.cleanup()`.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: solderpunk/AV-98#35
No description provided.