If one handle gets permissionerror, close other one before return.
This commit is contained in:
parent
6a63454f62
commit
2dad632122
1 changed files with 7 additions and 1 deletions
|
@ -409,7 +409,13 @@ def copy_file(
|
||||||
log.debug('Opening handles.')
|
log.debug('Opening handles.')
|
||||||
source_handle = handlehelper(source, 'rb')
|
source_handle = handlehelper(source, 'rb')
|
||||||
destination_handle = handlehelper(destination, 'wb')
|
destination_handle = handlehelper(destination, 'wb')
|
||||||
if None in (source_handle, destination_handle):
|
|
||||||
|
if source_handle is None and destination_handle:
|
||||||
|
destination_handle.close()
|
||||||
|
return [destination, 0]
|
||||||
|
|
||||||
|
if destination_handle is None:
|
||||||
|
source_handle.close()
|
||||||
return [destination, 0]
|
return [destination, 0]
|
||||||
|
|
||||||
if validate_hash:
|
if validate_hash:
|
||||||
|
|
Loading…
Reference in a new issue