From: Rob Browning Date: Sun, 6 May 2018 17:19:18 +0000 (-0500) Subject: vfs.copy_item: don't try to copy an integer mode X-Git-Tag: 0.30~81 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=d743b58427df26a64976412e25e7a0436cf56963 vfs.copy_item: don't try to copy an integer mode Signed-off-by: Rob Browning Tested-by: Rob Browning --- 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."""