Merge lp:~facundo/ubuntuone-client/lr-file-deletion-564774 into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Facundo Batista
Approved revision: 500
Merged at revision: not available
Proposed branch: lp:~facundo/ubuntuone-client/lr-file-deletion-564774
Merge into: lp:ubuntuone-client
Diff against target: 71 lines (+39/-6)
2 files modified
tests/syncdaemon/test_localrescan.py (+25/-0)
ubuntuone/syncdaemon/local_rescan.py (+14/-6)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/lr-file-deletion-564774
Reviewer Review Type Date Requested Status
John O'Brien (community) Approve
Tim Cole (community) Approve
Review via email: mp+23567@code.launchpad.net

Commit message

Don't delete the file in an interrupted download with lost partial.

Description of the change

Don't delete the file in an interrupted download with lost partial.

Test included.

To post a comment you must log in.
Revision history for this message
Tim Cole (tcole) wrote :

Looks like an improvement, I think.

review: Approve
Revision history for this message
John O'Brien (jdobrien) wrote :

Good test. Tests pass in client and integration tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/syncdaemon/test_localrescan.py'
--- tests/syncdaemon/test_localrescan.py 2010-04-12 19:29:50 +0000
+++ tests/syncdaemon/test_localrescan.py 2010-04-16 17:23:17 +0000
@@ -1484,6 +1484,31 @@
1484 self.startTest(check)1484 self.startTest(check)
1485 return self.deferred1485 return self.deferred
14861486
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 def test_SERVER_file_content(self):1512 def test_SERVER_file_content(self):
1488 """We were downloading the file, but it was interrupted, and changed"""1513 """We were downloading the file, but it was interrupted, and changed"""
1489 # create the file in metadata1514 # create the file in metadata
14901515
=== modified file 'ubuntuone/syncdaemon/local_rescan.py'
--- ubuntuone/syncdaemon/local_rescan.py 2010-04-12 19:29:50 +0000
+++ ubuntuone/syncdaemon/local_rescan.py 2010-04-16 17:23:17 +0000
@@ -507,17 +507,25 @@
507 else:507 else:
508 events.append(('FS_FILE_DELETE', fullname))508 events.append(('FS_FILE_DELETE', fullname))
509 else:509 else:
510 if changed not in ("SERVER", "NONE", "LOCAL"):510 if changed == 'SERVER':
511 # download interruped and partial lost
512 log_debug("comp yield: file %r not in disk, in SERVER "
513 "state, without partial!", fullname)
514 mdobj = self.fsm.get_by_path(fullname)
515 self.fsm.set_by_mdid(mdobj.mdid,
516 server_hash=mdobj.local_hash)
517 self.fsm.remove_partial(mdobj.node_id, mdobj.share_id)
518 elif changed in ('NONE', 'LOCAL'):
519 # if it had content somewhen, now is really gone (otherwise
520 # it was never really created in the disk)
521 log_info("comp yield: file %r is gone!", fullname)
522 events.append(('FS_FILE_DELETE', fullname))
523 else:
511 # bad metadata524 # bad metadata
512 m = "Bad 'changed': removing MD from file %r"525 m = "Bad 'changed': removing MD from file %r"
513 log_debug(m, fullname)526 log_debug(m, fullname)
514 self.fsm.delete_metadata(fullname)527 self.fsm.delete_metadata(fullname)
515 continue
516528
517 # if it had content somewhen, now is gone (otherwise it was
518 # never really created in the disk)
519 log_info("comp yield: file %r is gone!", fullname)
520 events.append(('FS_FILE_DELETE', fullname))
521 return events, to_scan_later529 return events, to_scan_later
522530
523 def _paths_filter(self, shrinfo, dirpath, len_shr_path):531 def _paths_filter(self, shrinfo, dirpath, len_shr_path):

Subscribers

People subscribed via source and target branches