storage/reflink: use context managers in is_supported()
Don't rely on garbage collection to close and remove the tempfiles.
This commit is contained in:
parent
867baf47d1
commit
5756e870bd
@ -456,7 +456,7 @@ def is_supported(dst_dir, src_dir=None):
|
||||
'''
|
||||
if src_dir is None:
|
||||
src_dir = dst_dir
|
||||
dst = tempfile.TemporaryFile(dir=dst_dir)
|
||||
src = tempfile.TemporaryFile(dir=src_dir)
|
||||
src.write(b'foo') # don't let any filesystem get clever with empty files
|
||||
return _attempt_ficlone(src, dst)
|
||||
with tempfile.TemporaryFile(dir=src_dir) as src, \
|
||||
tempfile.TemporaryFile(dir=dst_dir) as dst:
|
||||
src.write(b'foo') # don't let any fs get clever with empty files
|
||||
return _attempt_ficlone(src, dst)
|
||||
|
Loading…
Reference in New Issue
Block a user