Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
 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}
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 def test_empty_missing(self):
     known = ['x']
     missing = []
     self.assertEqual(util.heal(known, missing), -1)