Merge lp://qastaging/~lucio.torre/ubuntuone-client/sd-fix-dataloss into lp://qastaging/ubuntuone-client

Proposed by Lucio Torre
Status: Merged
Approved by: Guillermo Gonzalez
Approved revision: 14
Merged at revision: not available
Proposed branch: lp://qastaging/~lucio.torre/ubuntuone-client/sd-fix-dataloss
Merge into: lp://qastaging/ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~lucio.torre/ubuntuone-client/sd-fix-dataloss
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
John Lenton (community) Approve
Review via email: mp+6604@code.qastaging.launchpad.net

Commit message

[r=chipaca, r=verterok] solve data loss issue when sync and LR miscommunicate

To post a comment you must log in.
Revision history for this message
Lucio Torre (lucio.torre) wrote :

fix https://bugs.edge.launchpad.net/ubunet/+bug/376684

now we create the files as soon as we know about them.

14. By Lucio Torre

add dir support

Revision history for this message
John Lenton (chipaca) wrote :

Ok.

review: Approve
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'canonical/ubuntuone/storage/syncdaemon/filesystem_manager.py'
2--- canonical/ubuntuone/storage/syncdaemon/filesystem_manager.py 2009-05-12 13:36:05 +0000
3+++ canonical/ubuntuone/storage/syncdaemon/filesystem_manager.py 2009-05-15 08:58:32 +0000
4@@ -759,6 +759,16 @@
5
6 return open(self.get_abspath(mdobj['share_id'], mdobj['path']))
7
8+ def create_file(self, mdid):
9+ '''create the file.'''
10+ mdobj = self.fs[mdid]
11+ if mdobj["is_dir"]:
12+ raise ValueError("You can only open files, not directories.")
13+
14+ # use os.open so this wont raise IN_CLOSE_WRITE
15+ fd = os.open(self.get_abspath(mdobj['share_id'], mdobj['path']), os.O_CREAT)
16+ os.close(fd)
17+
18 def _share_relative_path(self, share_id, path):
19 """ returns the relative path from the share_id. """
20 share = self._get_share(share_id)
21
22=== modified file 'canonical/ubuntuone/storage/syncdaemon/sync.py'
23--- canonical/ubuntuone/storage/syncdaemon/sync.py 2009-05-12 13:36:05 +0000
24+++ canonical/ubuntuone/storage/syncdaemon/sync.py 2009-05-15 08:58:32 +0000
25@@ -185,6 +185,13 @@
26 except Exception:
27 return default
28
29+ def make_file(self):
30+ "create the local empty file"
31+ self.fs.create_file(self.get_mdid())
32+
33+
34+
35+
36 def loglevel(lvl):
37 """Make a function that logs at lvl log level."""
38 def level_log(self, message, *args, **kwargs):
39@@ -362,12 +369,14 @@
40 def file_conflict(self, event, params, hash, crc32, size):
41 """This file is in conflict."""
42 self.key.move_to_conflict()
43+ self.key.make_file()
44
45 def local_file_conflict(self, event, params, hash):
46 """This file is in conflict."""
47 self.key.move_to_conflict()
48 self.m.action_q.cancel_upload(share_id=self.key['share_id'],
49 node_id=self.key['node_id'])
50+ self.key.make_file()
51 self.get_file(event, params, hash)
52
53 def merge_directory(self, event, params, hash):
54@@ -461,6 +470,7 @@
55 self.m.fs.set_node_id(path, node_id)
56 self.key.set(server_hash="")
57 self.key.set(local_hash="")
58+ self.key.make_file()
59 self.m.action_q.query([(share_id, node_id, "")])
60
61 def new_file_on_server_with_local(self, event, params, share_id,
62@@ -537,11 +547,6 @@
63 self.m.action_q.query([
64 (self.key["share_id"], self.key["node_id"], "")])
65
66-
67- def new_while_server(self, event, parms, path):
68- """fs new file while file in server state"""
69- self.key.move_to_conflict()
70-
71 def new_local_file(self, event, parms, path):
72 """a new local file was created"""
73 # XXX: lucio.torre: we should use markers here
74
75=== modified file 'canonical/ubuntuone/storage/syncdaemon/u1fsfsm.ods'
76Binary files canonical/ubuntuone/storage/syncdaemon/u1fsfsm.ods 2009-05-12 13:36:05 +0000 and canonical/ubuntuone/storage/syncdaemon/u1fsfsm.ods 2009-05-15 08:58:32 +0000 differ
77=== modified file 'canonical/ubuntuone/storage/syncdaemon/u1fsfsm.py'
78--- canonical/ubuntuone/storage/syncdaemon/u1fsfsm.py 2009-05-12 13:36:05 +0000
79+++ canonical/ubuntuone/storage/syncdaemon/u1fsfsm.py 2009-05-15 08:58:32 +0000
80@@ -1574,9 +1574,9 @@
81 'STATE_OUT': {u'changed': u'NONE',
82 u'has_metadata': u'T',
83 u'is_directory': u'F'}},
84- {'ACTION': u'rename to .conflict.n',
85- 'ACTION_FUNC': u'new_while_server',
86- 'COMMENTS': u'this action sounds resonable. But I dont know how to get to this state+message',
87+ {'ACTION': u'',
88+ 'ACTION_FUNC': u'nothing',
89+ 'COMMENTS': u'ignore this. We created the file.',
90 'PARAMETERS': {u'hash_eq_local_hash': u'NA',
91 u'hash_eq_server_hash': u'NA',
92 u'not_authorized': u'NA',

Subscribers

People subscribed via source and target branches