diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-13 15:25:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-13 15:52:23 +0200 |
commit | 41307f5a104c787544b7ffd5d3d515f48915b748 (patch) | |
tree | 4148f0651cd336502444a8de336ff50b47de022a | |
parent | 6e3e2de88c5a0ade97ddbfd325583bddc2bbea74 (diff) | |
download | obnam-41307f5a104c787544b7ffd5d3d515f48915b748.tar.gz |
Use well-known blobs, not objects in client-list
-rw-r--r-- | obnamlib/fmt_ga/client_list.py | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/obnamlib/fmt_ga/client_list.py b/obnamlib/fmt_ga/client_list.py index 26929b3f..14f2f169 100644 --- a/obnamlib/fmt_ga/client_list.py +++ b/obnamlib/fmt_ga/client_list.py @@ -17,7 +17,6 @@ import errno -import os import random import obnamlib @@ -25,6 +24,8 @@ import obnamlib class GAClientList(object): + _well_known_blob = 'root' + def __init__(self): self._hooks = None self._fs = None @@ -62,11 +63,13 @@ class GAClientList(object): def _save_data(self): assert self._data is not None blob = obnamlib.serialise_object(self._data) - filename = self._get_filename() - self._fs.overwrite_file(filename, blob) - def _get_filename(self): - return os.path.join(self.get_dirname(), 'data.dat') + bag_store = obnamlib.BagStore() + bag_store.set_location(self._fs, self.get_dirname()) + + blob_store = obnamlib.BlobStore() + blob_store.set_bag_store(bag_store) + blob_store.put_well_known_blob(self._well_known_blob, blob) def get_client_names(self): self._load_data() @@ -79,16 +82,23 @@ class GAClientList(object): assert self._data is not None else: assert self._data is None + if not self._data_is_loaded: - filename = self._get_filename() - if self._fs.exists(filename): - blob = self._fs.cat(filename) - self._data = obnamlib.deserialise_object(blob) - assert self._data is not None - else: + bag_store = obnamlib.BagStore() + bag_store.set_location(self._fs, self.get_dirname()) + + blob_store = obnamlib.BlobStore() + blob_store.set_bag_store(bag_store) + blob = blob_store.get_well_known_blob(self._well_known_blob) + + if blob is None: self._data = { 'clients': {}, } + else: + self._data = obnamlib.deserialise_object(blob) + assert self._data is not None + self._data_is_loaded = True def get_client_dirname(self, client_name): |