~verterok/ubuntuone-client/fix-452682

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_localrescan.py

  • Committer: Tarmac
  • Author(s): facundo at com
  • Date: 2010-04-16 19:20:16 UTC
  • mfrom: (499.1.1 lr-file-deletion-564774)
  • Revision ID: dobey@wayofthemonkey.com-20100416192016-u9xi0moyp59fw203
Don't delete the file in an interrupted download with lost partial.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1484
1484
        self.startTest(check)
1485
1485
        return self.deferred
1486
1486
 
 
1487
    def test_SERVER_no_file(self):
 
1488
        """We just queued the Download, and it was interrupted."""
 
1489
        # create the file in metadata
 
1490
        path = os.path.join(self.share.path, "a")
 
1491
        mdid = self.fsm.create(path, self.share.volume_id, is_dir=False, node_id="uuid")
 
1492
        partial_path = os.path.join(self.fsm.partials_dir,
 
1493
                                mdid + ".u1partial." + os.path.basename(path))
 
1494
 
 
1495
        # this mimic Sync.get_file
 
1496
        self.fsm.set_by_mdid(mdid, server_hash="blah-hash-blah")
 
1497
        self.fsm.create_partial("uuid", self.share.volume_id)
 
1498
 
 
1499
        # now, for some reason, we lose the partial file
 
1500
        os.remove(partial_path)
 
1501
 
 
1502
        def check(_):
 
1503
            """arrange the metadata so later server_rescan will do ok"""
 
1504
            self.assertEqual(self.eq.pushed, [])
 
1505
            mdobj = self.fsm.get_by_mdid(mdid)
 
1506
            self.assertFalse(mdobj.info.is_partial)
 
1507
            self.assertEqual(mdobj.server_hash, mdobj.local_hash)
 
1508
 
 
1509
        self.startTest(check)
 
1510
        return self.deferred
 
1511
 
1487
1512
    def test_SERVER_file_content(self):
1488
1513
        """We were downloading the file, but it was interrupted, and changed"""
1489
1514
        # create the file in metadata