"""
Add a new lease on the given bucket. If the renew_secret matches an
existing lease, that lease will be renewed instead. If there is no
- bucket for the given storage_index, IndexError will be raised.
+ bucket for the given storage_index, return silently. (note that in
+ tahoe-1.3.0 and earlier, IndexError was raised if there was no
+ bucket)
"""
return None
lease_info = LeaseInfo(owner_num,
renew_secret, cancel_secret,
new_expire_time, self.my_nodeid)
- found_buckets = False
for sf in self._iter_share_files(storage_index):
- found_buckets = True
- # note: if the share has been migrated, the renew_lease()
- # call will throw an exception, with information to help the
- # client update the lease.
sf.add_or_renew_lease(lease_info)
self.add_latency("add-lease", time.time() - start)
- if not found_buckets:
- raise IndexError("no such storage index to do add-lease")
-
+ return None
def remote_renew_lease(self, storage_index, renew_secret):
start = time.time()
self.failUnlessEqual(len(leases), 3)
self.failUnlessEqual(set([l.renew_secret for l in leases]), set([rs1, rs2, rs2a]))
- # add-lease on a missing storage index is an error
- self.failUnlessRaises(IndexError, ss.remote_add_lease, "si18", "", "")
+ # add-lease on a missing storage index is silently ignored
+ self.failUnlessEqual(ss.remote_add_lease("si18", "", ""), None)
# check that si0 is readable
readers = ss.remote_get_buckets("si0")
s0 = MutableShareFile(os.path.join(bucket_dir, "0"))
self.failUnlessEqual(len(s0.debug_get_leases()), 1)
- # add-lease on a missing storage index is an error
- self.failUnlessRaises(IndexError, ss.remote_add_lease, "si18", "", "")
+ # add-lease on a missing storage index is silently ignored
+ self.failUnlessEqual(ss.remote_add_lease("si18", "", ""), None)
# re-allocate the slots and use the same secrets, that should update
# the lease