summaryrefslogtreecommitdiff
path: root/obnamlib/bag_store.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-05-16 19:02:04 +0300
committerLars Wirzenius <liw@liw.fi>2015-05-16 19:07:48 +0300
commit8009e62bedf764941019a85f40ccac92ed038e57 (patch)
tree0a8cb876f047e7ea5f69bf91f4baf513e540382a /obnamlib/bag_store.py
parent959622b90e8140346789d1d90c0b8a78309bce39 (diff)
downloadobnam-8009e62bedf764941019a85f40ccac92ed038e57.tar.gz
Add BagStore.has_bag
Diffstat (limited to 'obnamlib/bag_store.py')
-rw-r--r--obnamlib/bag_store.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/obnamlib/bag_store.py b/obnamlib/bag_store.py
index e95d385d..abe33baf 100644
--- a/obnamlib/bag_store.py
+++ b/obnamlib/bag_store.py
@@ -52,6 +52,14 @@ class BagStore(object):
serialised = self._fs.cat(filename)
return deserialise_bag(serialised)
+ def has_bag(self, bag_id):
+ filename = self._make_bag_filename(bag_id)
+ try:
+ st = self._fs.lstat(filename)
+ except (IOError, OSError) as e: # pragma: no cover
+ return False
+ return st.st_size > 0
+
def get_bag_ids(self):
for pathname, st in self._fs.scan_tree(self._dirname):
if self._is_bag_filename(pathname):