From d743b58427df26a64976412e25e7a0436cf56963 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 6 May 2018 12:19:18 -0500 Subject: [PATCH] vfs.copy_item: don't try to copy an integer mode Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/vfs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bup/vfs.py b/lib/bup/vfs.py index 0ac31a9..1c67577 100644 --- a/lib/bup/vfs.py +++ b/lib/bup/vfs.py @@ -13,7 +13,9 @@ Each path is represented by an item that has least an item.meta which may be either a Metadata object, or an integer mode. Functions like item_mode() and item_size() will return the mode and size in either case. Any item.meta Metadata instances must not be modified directly. -Make a copy to modify via item.meta.copy() if needed. +Make a copy to modify via item.meta.copy() if needed, or call +copy_item(). + The want_meta argument is advisory for calls that accept it, and it may not be honored. Callers must be able to handle an item.meta value @@ -312,9 +314,9 @@ def copy_item(item): """ meta = getattr(item, 'meta', None) - if not meta: - return item - return(item._replace(meta=meta.copy())) + if isinstance(meta, Metadata): + return(item._replace(meta=meta.copy())) + return item def item_mode(item): """Return the integer mode (stat st_mode) for item.""" -- 2.39.2