From bfaa23c896df72b8b34ad70c723d05a206a56c19 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 11 Jun 2017 18:27:14 +0300 Subject: Fix: Make "obnam forget" for GA delete unused chunks --- obnamlib/fmt_ga/chunk_store.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'obnamlib/fmt_ga/chunk_store.py') diff --git a/obnamlib/fmt_ga/chunk_store.py b/obnamlib/fmt_ga/chunk_store.py index 9f916276..da1ed4bd 100644 --- a/obnamlib/fmt_ga/chunk_store.py +++ b/obnamlib/fmt_ga/chunk_store.py @@ -1,4 +1,4 @@ -# Copyright 2015 Lars Wirzenius +# Copyright 2015,2017 Lars Wirzenius # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -65,6 +65,25 @@ class GAChunkStore(object): filename=None) return content + def get_bag_id(self, chunk_id): + bag_id, _ = obnamlib.parse_object_id(chunk_id) + return bag_id + + def get_chunks_in_bag(self, bag_id): + try: + bag = self._bag_store.get_bag(bag_id) + except EnvironmentError: + pass + else: + for i in range(len(bag)): + yield obnamlib.make_object_id(bag_id, i) + + def remove_bag(self, bag_id): + try: + self._bag_store.remove_bag(bag_id) + except EnvironmentError: + pass + def has_chunk(self, chunk_id): # This is ugly, 'cause it requires reading in the whole bag. # We could easily check if the bag exists, but not whether it -- cgit v1.2.1