If one handle gets permissionerror, close other one before return.

master
Ethan Dalool 2020-02-03 19:29:27 -08:00
parent 6a63454f62
commit 2dad632122
1 changed files with 7 additions and 1 deletions

View File

@ -409,7 +409,13 @@ def copy_file(
log.debug('Opening handles.')
source_handle = handlehelper(source, 'rb')
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]
if validate_hash: