vorta icon indicating copy to clipboard operation
vorta copied to clipboard

cleanup temp files at end of job

Open marco44 opened this issue 3 years ago • 2 comments
trafficstars

Closes #1383

This only has been tested locally, but seems to work. The file is only cleaned in case of a success

marco44 avatar Aug 13 '22 10:08 marco44

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

m3nu avatar Aug 13 '22 18:08 m3nu

(Linting errors are fixed now. Thanks, @real-yfprojects)

m3nu avatar Aug 13 '22 18:08 m3nu

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

marco44 avatar Aug 14 '22 06:08 marco44

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.

m3nu avatar Aug 14 '22 11:08 m3nu

Should be ok now, extract is also done

marco44 avatar Aug 14 '22 15:08 marco44

Thanks for implementing this @marco44 and congrats to your first contribution! 🎉

real-yfprojects avatar Aug 15 '22 12:08 real-yfprojects