fix storage server to handle the case that it has no directory at all when someone asks for buckets

This commit is contained in:
Zooko O'Whielacronx 2007-03-30 17:12:07 -07:00
parent 826ce43be7
commit 1a20e5d01b

View File

@ -116,7 +116,12 @@ class StorageServer(service.MultiService, Referenceable):
def remote_get_buckets(self, verifierid): def remote_get_buckets(self, verifierid):
bucketreaders = {} # k: sharenum, v: BucketReader bucketreaders = {} # k: sharenum, v: BucketReader
verifierdir = os.path.join(self.storedir, idlib.b2a(verifierid)) verifierdir = os.path.join(self.storedir, idlib.b2a(verifierid))
for f in os.listdir(verifierdir): try:
_assert(NUM_RE.match(f), f) for f in os.listdir(verifierdir):
bucketreaders[int(f)] = BucketReader(os.path.join(verifierdir, f)) _assert(NUM_RE.match(f), f)
bucketreaders[int(f)] = BucketReader(os.path.join(verifierdir, f))
except OSError:
# Commonly caused by there being no buckets at all.
pass
return bucketreaders return bucketreaders