diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-06-11 22:11:51 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-06-11 22:11:51 +0300 |
commit | d68079f0a46b2022d839d16993baaa54a4585866 (patch) | |
tree | c064b9ec13484c42951908038e08cc936dbf3388 | |
parent | 64407f758296e752d0db41866d3509e3b499d377 (diff) | |
download | obnam-d68079f0a46b2022d839d16993baaa54a4585866.tar.gz |
Fix: logic for checking if chunks are unused
-rw-r--r-- | obnamlib/fmt_ga/indexes.py | 11 | ||||
-rwxr-xr-x | test-ga-forget | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/obnamlib/fmt_ga/indexes.py b/obnamlib/fmt_ga/indexes.py index 2ca76bd7..6823e68d 100644 --- a/obnamlib/fmt_ga/indexes.py +++ b/obnamlib/fmt_ga/indexes.py @@ -16,6 +16,7 @@ # =*= License: GPL-3+ =*= +import logging import os import obnamlib @@ -198,8 +199,14 @@ class GAChunkIndexes(object): chunk_store, unused_chunks) for bag_id in maybe_unused_bags: chunk_ids = chunk_store.get_chunks_in_bag(bag_id) + logging.debug('remove_unused_chunk: can bag %r be removed?', bag_id) + for chunk_id in chunk_ids: + logging.debug('remove_unused_chunk: chunk %r, used: %r', chunk_id, self.is_chunk_used_by_anyone(chunk_id)) if not self.any_chunk_is_used_by_someone(chunk_ids): + logging.debug('remove_unused_chunk: remove bag %r', bag_id) chunk_store.remove_bag(bag_id) + else: + logging.debug('remove_unused_chunk: bag %r cannot be removed', bag_id) def get_unused_chunks(self): return [ @@ -223,8 +230,8 @@ class GAChunkIndexes(object): ) def any_chunk_is_used_by_someone(self, chunk_ids): - return all( - not self.is_chunk_used_by_anyone(chunk_id) + return any( + self.is_chunk_used_by_anyone(chunk_id) for chunk_id in chunk_ids ) diff --git a/test-ga-forget b/test-ga-forget index 5c0a5a17..4040c803 100755 --- a/test-ga-forget +++ b/test-ga-forget @@ -13,7 +13,7 @@ obnam() } rm -rf t.data t.repo t.log -genbackupdata --create 1G t.data +genbackupdata --create 100M t.data obnam backup genid="$(obnam genids)" obnam forget "$genid" |