From 65f766928c3f472e388dc963e60c149ed71b0d47 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 8 May 2021 09:39:13 -0700 Subject: [PATCH] Add 'written' to copy_file results dotdict. --- voussoirkit/spinal.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/voussoirkit/spinal.py b/voussoirkit/spinal.py index 6ae16b9..d4cd408 100644 --- a/voussoirkit/spinal.py +++ b/voussoirkit/spinal.py @@ -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(