]> arthur.barton.de Git - bup.git/blobdiff - lib/bup/vfs.py
vfs.copy_item: don't try to copy an integer mode
[bup.git] / lib / bup / vfs.py
index 0ac31a99d103afd0cefa91359819ae24c711ed6a..1c67577f000b6c458c781edd7086e050fe1d57e5 100644 (file)
@@ -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."""