Temp files being left over
Hi,
I'm noticing some temp files being left over when running copier
Typically under windows under the C:\Users\username\AppData\Local\Temp directory
such as copier.vcs.clone.sxn86nzf
I'm running copier using a template that's located on the disk as a directory But I'm noticing it only happens for templates / directories that are setup as a git repo. If there's no .git sub-directory inside the template directory then no temp directory is created (I'm guessing since it doesn't have to check the git tags)
Is this expected behaviour? or should copier be cleaning up it's temp dirs after running?
Environment
- OS: Windows
- Copier version: 6.1.0
- Python version: 3.9.13
- Installation method: pipx+pypi,
Copier should either clean that up, or at least be able to reuse it if the same refs are requested. This is definitely an issue.
El mié, 29 jun 2022 18:19, Hecatron @.***> escribió:
Hi, I'm noticing some temp files being left over when running copier Typically under windows under the C:\Users\username\AppData\Local\Temp directory such as copier.vcs.clone.sxn86nzf
I'm running copier using a template that's located on the disk as a directory But I'm noticing it only happens for templates / directories that are setup as a git repo. If there's no .git sub-directory inside the template directory then no temp directory is created (I'm guessing since it doesn't have to check the git tags)
Is this expected behaviour? or should copier be cleaning up it's temp dirs after running?
Environment
- OS: Windows
- Copier version: 6.1.0
- Python version: 3.9.13
- Installation method: pipx+pypi,
— Reply to this email directly, view it on GitHub https://github.com/copier-org/copier/issues/709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHNXDLF4PWRTLWVEPF2GTTVRSASXANCNFSM52GQCMHA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
We've seen issues with temporary directories on Windows before.
- https://github.com/copier-org/copier/issues/345
- https://github.com/copier-org/copier/blob/8ab7bd0845b06a0259549d6c4c2e61b8c632746a/copier/tools.py#L153
Maybe some other places in the code need to use the custom TemporaryDirectory class.
It happens on Linux too.
Hey @yajo, I'm wondering how this could be resolved. I've checked the code and it seems we should try to remove the worker.template.local_abspath once the copy or update is done. Should we simply do that in the run_update and run_copy functions in in main.py? Or should we transform the worker into a context manager?
with Worker(dst_path=Path(dst_path), **kwargs) as worker:
worker.run_update()
Then the worker class can have an __exit__ method that takes care of cleaning everything up?