Add 'written' to copy_file results dotdict.

This commit is contained in:
voussoir 2021-05-08 09:39:13 -07:00
parent 9bdee227b3
commit 65f766928c
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -389,8 +389,9 @@ def copy_file(
and its hash will be compared against the hash of the source file.
If hash_class is None, then the global HASH_CLASS is used.
Returns a dotdict containing at least `source`, `destination`,
and `written_bytes`. (Written bytes is 0 if the file already existed.)
Returns a dotdict containing at least `source`, `destination` (Pathclass),
`written` (False if file was skipped, True if written), and
`written_bytes` (integer).
'''
# Prepare parameters
if not is_xor(destination, destination_new_root):
@ -419,6 +420,7 @@ def copy_file(
results = dotdict.DotDict(
source=source,
destination=destination,
written=False,
written_bytes=0,
default=None,
)
@ -511,6 +513,7 @@ def copy_file(
destination_handle.close()
log.debug('Copying metadata.')
shutil.copystat(source.absolute_path, destination.absolute_path)
results.written = True
if validate_hash:
verify_hash(