created. It is an error to attempt to create a container that already exists.
"""
+ def list_container(prefix=str):
+ """
+ Return a Deferred that fires with a list of ContainerItems for all
+ objects in the backend container. If prefix is given, restrict the
+ list to objects having keys with the given prefix.
+ """
+
class IShareSet(Interface):
def get_storage_index():
def create_container(self):
return self._container.create()
+ def list_container(self, prefix=''):
+ d = self._container.list_objects(prefix)
+ d.addCallback(lambda listing: listing.contents)
+ return d
+
class CloudShareSet(ShareSet):
implements(IShareSet)
# so must use its TubID as a permutation-seed.
return bool(set(fileutil.listdir(self._sharedir)) - set(["incoming"]))
+ def list_container(self, prefix=''):
+ def _not_implemented():
+ raise NotImplementedError("the disk backend does not support listing container contents.\n" +
+ "Use 'tahoe debug catalog-shares' instead.")
+ return defer.execute(_not_implemented)
+
class DiskShareSet(ShareSet):
implements(IShareSet)
IShareForReading, IShareForWriting, IMutableShare
from allmydata.util.assertutil import precondition
+from allmydata.util.listutil import concat
from allmydata.storage.backends.base import Backend, ShareSet, empty_check_testv
from allmydata.storage.bucket import BucketWriter
from allmydata.storage.common import si_b2a
+from allmydata.storage.backends.base import ContainerItem
def configure_null_backend(storedir, config):
def fill_in_space_stats(self, stats):
pass
+ def list_container(self, prefix=''):
+ return defer.succeed(concat([s._list_items() for s in self.get_sharesets_for_prefix(prefix)]))
+
class NullShareSet(ShareSet):
implements(IShareSet)
def get_overhead(self):
return 0
+ def _list_items(self):
+ sistr = si_b2a(self.storage_index)
+ return [ContainerItem("shares/%s/%s/%d" % (sistr[:2], sistr, shnum), None, "", 0, "STANDARD", None)
+ for shnum in set.union(self._immutable_shnums, self._mutable_shnums)]
+
def _locked_get_shares(self):
shares = {}
for shnum in self._immutable_shnums: