def self_heal(self, known_chunks=None, missing_chunks=None): """ Try to use known chunks to fill in gaps """ if known_chunks is None: known_chunks = self.get_known_chunks() if missing_chunks is None: missing_chunks = self.get_missing_chunks() heal(known_chunks, missing_chunks)
def cmd_heal(self, args): known = [] missing = [] for r in self.repos.values(): known.extend(r.get_known_chunks()) missing.extend(r.get_missing_chunks()) saved = heal(known, missing) return {"status": "ok", "saved": saved}
def test_something_to_do(self): known = [Mock(id="x", length=10)] missing = [Mock(id="x", length=10)] self.assertEqual(util.heal(known, missing), 10) self.assertEqual(missing[0].save_data.call_count, 1)
def test_empty_missing(self): known = ['x'] missing = [] self.assertEqual(util.heal(known, missing), -1)