vorta
vorta copied to clipboard
cleanup temp files at end of job
Closes #1383
This only has been tested locally, but seems to work. The file is only cleaned in case of a success
If it's all temp files, we want to clean up, this would work too and is less risky. The reference could go in your list. So only the deletion is slightly different.
# create a temporary file and write some data to it
>>> fp = tempfile.TemporaryFile()
...
# close the file, it will be removed
>>> fp.close()
https://docs.python.org/3/library/tempfile.html#examples
(Linting errors are fixed now. Thanks, @real-yfprojects)
Ok, so I changed this to use the close method instead, you're right, it's slightly simpler.
If you're ok with this way of doing things, I'll implement it for extract too
Looks good. Anything that uses tmpfile would be best. Only create and extract from what I see. Thanks!
@real-yfprojects: Let's cherry-pick this into the borg-v2 branch soon. Will be harder to merge, if we really start using Black there.
Should be ok now, extract is also done
Thanks for implementing this @marco44 and congrats to your first contribution! 🎉