Merge lp:~verterok/ubuntuone-client/hashnone-to-reupload into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: dobey
Approved revision: 1258
Merged at revision: 1259
Proposed branch: lp:~verterok/ubuntuone-client/hashnone-to-reupload
Merge into: lp:ubuntuone-client
Diff against target: 78 lines (+23/-9)
2 files modified
tests/syncdaemon/test_sync.py (+15/-7)
ubuntuone/syncdaemon/sync.py (+8/-2)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/hashnone-to-reupload
Reviewer Review Type Date Requested Status
dobey (community) Approve
Facundo Batista (community) Approve
Review via email: mp+110420@code.launchpad.net

Commit message

Force a "reput from local" when the server_hash (that came in the delta) is ""

Description of the change

Force a "reput from local" when the server_hash (that came in the delta) is ""

To post a comment you must log in.
Revision history for this message
Facundo Batista (facundo) :
review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_sync.py'
2--- tests/syncdaemon/test_sync.py 2012-04-23 14:41:17 +0000
3+++ tests/syncdaemon/test_sync.py 2012-06-14 21:22:19 +0000
4@@ -387,20 +387,29 @@
5 self.sync._handle_SV_HASH_NEW(mdobj.share_id, mdobj.node_id, '')
6 self.assertTrue(self.called)
7
8- def test_SV_HASH_NEW_with_file_uploadinterrupted_coverage(self):
9- """A SV_HASH_NEW is received after upload interrupted."""
10+ def test_SV_HASH_NEW_with_special_hash(self):
11+ """A SV_HASH_NEW is received with hash in None, don't care state."""
12 self.called = False
13
14- # create a file and put it in local, without server_hash, as
15- # if the upload was cut in the middle after the make file
16+ def fake_meth(_, event, params, hash):
17+ """Wrap SSMR.reput_file_from_local to test."""
18+ self.assertEqual(event, 'SV_HASH_NEW')
19+ self.assertEqual(hash, '')
20+ self.called = True
21+ self.patch(SyncStateMachineRunner, 'reput_file_from_local', fake_meth)
22+
23+ # create a file and leave it as NONE state
24 somepath = os.path.join(self.root, 'somepath')
25 mdid = self.fsm.create(somepath, '', node_id='node_id')
26- self.fsm.set_by_mdid(mdid, local_hash='somehash', crc32='crc32',
27- stat='stat', size='size')
28+ self.fsm.set_by_mdid(mdid, local_hash='somehsh', server_hash='somehsh',
29+ crc32='crc32', stat='stat', size='size')
30
31 # send the event with no content and check
32 mdobj = self.fsm.get_by_mdid(mdid)
33 self.sync._handle_SV_HASH_NEW(mdobj.share_id, mdobj.node_id, '')
34+ self.assertTrue(self.called)
35+ mdobj = self.fsm.get_by_mdid(mdid)
36+ self.assertEqual(mdobj.server_hash, '')
37
38 def test_AQ_FILE_NEW_OK_with_md_in_none(self):
39 """Created the file, and MD says it's in NONE."""
40@@ -991,7 +1000,6 @@
41 with self._test_putcontent_upload_id(with_upload_id=False):
42 self.ssmr.reput_file_from_local("SV_HASH_NEW", None, '')
43
44-
45 def test_commit_file_without_partial(self):
46 """The .partial is lost when commiting the file."""
47 # create the partial correctly, and break it!
48
49=== modified file 'ubuntuone/syncdaemon/sync.py'
50--- ubuntuone/syncdaemon/sync.py 2012-04-09 20:08:42 +0000
51+++ ubuntuone/syncdaemon/sync.py 2012-06-14 21:22:19 +0000
52@@ -589,10 +589,10 @@
53 """Starts the scan again on a dir."""
54 self.m.lr.scan_dir(self.key['mdid'], self.key['path'], udfmode)
55
56- def reput_file_from_local(self, event, params, hash):
57+ def reput_file_from_local(self, event, params, hash_value):
58 """Re put the file from its local state."""
59 self.m.action_q.cancel_upload(share_id=self.key['share_id'],
60- node_id=self.key['node_id'])
61+ node_id=self.key['node_id'])
62
63 local_hash = self.key['local_hash']
64 previous_hash = self.key['server_hash']
65@@ -841,7 +841,13 @@
66 """on SV_HASH_NEW. No longer called by EQ, only internally."""
67 key = FSKey(self.m.fs, share_id=share_id, node_id=node_id)
68 log = FileLogger(self.logger, key)
69+
70 ssmr = SyncStateMachineRunner(self.fsm, self.m, key, log)
71+ if hash == "":
72+ # Special case for hash == "", aka broken node.
73+ # Set the server_hash = hash to force LOCAL state
74+ key.set(server_hash=hash)
75+ key.sync()
76 ssmr.signal_event_with_hash("SV_HASH_NEW", hash)
77
78 def _handle_SV_FILE_NEW(self, share_id, node_id, parent_id, name):

Subscribers

People subscribed via source and target branches