Merge lp:~verterok/ubuntuone-client/fix-692496 into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Facundo Batista
Approved revision: 780
Merged at revision: 786
Proposed branch: lp:~verterok/ubuntuone-client/fix-692496
Merge into: lp:ubuntuone-client
Diff against target: 111 lines (+12/-38)
5 files modified
tests/syncdaemon/test_fsm.py (+0/-19)
tests/syncdaemon/test_localrescan.py (+10/-1)
ubuntuone/syncdaemon/filesystem_manager.py (+0/-8)
ubuntuone/syncdaemon/local_rescan.py (+2/-0)
ubuntuone/syncdaemon/sync.py (+0/-10)
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/fix-692496
Reviewer Review Type Date Requested Status
Lucio Torre (community) Approve
Facundo Batista (community) Approve
Review via email: mp+44272@code.launchpad.net

Commit message

Fix local rescan to handle the case of the stat in metadata being None and remove unused refrsh_stat methods.

Description of the change

this branch fix local rescan to handle the case of the stat in metadata being None, also remove the unused refresh_stat methods from fsm and sync.

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

+1

review: Approve
Revision history for this message
Facundo Batista (facundo) wrote :

 ** Merging the branch
 M tests/syncdaemon/test_fsm.py
 M tests/syncdaemon/test_localrescan.py
 M ubuntuone/syncdaemon/filesystem_manager.py
 M ubuntuone/syncdaemon/local_rescan.py
 M ubuntuone/syncdaemon/sync.py
Text conflict in tests/syncdaemon/test_fsm.py
1 conflicts encountered.

review: Needs Fixing
780. By Guillermo Gonzalez

merge with trunk

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

merged with trunk & pushed.

Revision history for this message
Facundo Batista (facundo) wrote :

Like it!

review: Approve
Revision history for this message
Lucio Torre (lucio.torre) wrote :

re approve rs

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_fsm.py'
2--- tests/syncdaemon/test_fsm.py 2011-01-03 20:36:27 +0000
3+++ tests/syncdaemon/test_fsm.py 2011-01-04 13:31:28 +0000
4@@ -1486,25 +1486,6 @@
5 mdobj = self.create_node("thisdir")
6 self.assertEqual(mdobj.stat, os.stat(path))
7
8- def test_refresh(self):
9- """Test that refresh_stat works."""
10- path = os.path.join(self.share.path, "thisfile")
11- open(path, "w").close()
12- mdobj = self.create_node("thisfile")
13- mdid = mdobj.mdid
14- oldstat = os.stat(path)
15- self.assertEqual(mdobj.stat, oldstat)
16-
17- # touch the file, it's not automagically updated
18- open(path, "w").close()
19- mdobj = self.fsm.get_by_mdid(mdid)
20- self.assertEqual(mdobj.stat, oldstat)
21-
22- # it's updated when asked
23- self.fsm.refresh_stat(path)
24- mdobj = self.fsm.get_by_mdid(mdid)
25- self.assertEqual(mdobj.stat, os.stat(path))
26-
27 def test_commit_partial(self):
28 """Test that it's updated in the commit."""
29 path = os.path.join(self.share.path, "thisfile")
30
31=== modified file 'tests/syncdaemon/test_localrescan.py'
32--- tests/syncdaemon/test_localrescan.py 2011-01-03 18:08:27 +0000
33+++ tests/syncdaemon/test_localrescan.py 2011-01-04 13:31:28 +0000
34@@ -1590,7 +1590,9 @@
35 # start a put file, and assume we got interrupted (no server hash)
36 pathhash = self._hash(path)
37 self.fsm.set_by_mdid(mdid, local_hash=pathhash, crc32='foo')
38- self.fsm.refresh_stat(path)
39+ mdobj = self.fsm.fs[mdid]
40+ mdobj["stat"] = os.lstat(path)
41+ self.fsm.fs[mdid] = mdobj
42
43 def check(_):
44 """Compare predictable args, and check fh factory."""
45@@ -2074,6 +2076,13 @@
46 self.startTest(check)
47 return self.deferred
48
49+ def test_check_stat_None(self):
50+ """Test check_stat with oldstat = None."""
51+ # create the file in metadata
52+ path = os.path.join(self.share.path, "a_file")
53+ self.fsm.create(path, self.share.volume_id, is_dir=False)
54+ self.assertTrue(self.lr.check_stat(path, None))
55+
56
57 class RootBadStateTests(TwistedBase):
58 """Test what happens with volume roots left in a bad state last time."""
59
60=== modified file 'ubuntuone/syncdaemon/filesystem_manager.py'
61--- ubuntuone/syncdaemon/filesystem_manager.py 2011-01-03 20:36:27 +0000
62+++ ubuntuone/syncdaemon/filesystem_manager.py 2011-01-04 13:31:28 +0000
63@@ -779,14 +779,6 @@
64 mdid = self._idx_node_id[(share_id, node_id)]
65 self.set_by_mdid(mdid, **kwargs)
66
67- def refresh_stat(self, path):
68- """Refresh the stat of a md object."""
69- log_debug("refresh stat to path=%r", path)
70- mdid = self._idx_path[path]
71- mdobj = self.fs[mdid]
72- mdobj["stat"] = get_stat(path)
73- self.fs[mdid] = mdobj
74-
75 def move_file(self, new_share_id, path_from, path_to):
76 """Move a file/dir from one point to the other."""
77 path_from = os.path.normpath(path_from)
78
79=== modified file 'ubuntuone/syncdaemon/local_rescan.py'
80--- ubuntuone/syncdaemon/local_rescan.py 2010-12-02 21:27:56 +0000
81+++ ubuntuone/syncdaemon/local_rescan.py 2011-01-04 13:31:28 +0000
82@@ -363,6 +363,8 @@
83 - st_size: it changed in size, surely different content
84 - st_mtime: the content could be different even having the same size
85 """
86+ if oldstat is None:
87+ return True
88 newstat = os.stat(fullname)
89 different = (newstat.st_ino != oldstat.st_ino or
90 newstat.st_size != oldstat.st_size or
91
92=== modified file 'ubuntuone/syncdaemon/sync.py'
93--- ubuntuone/syncdaemon/sync.py 2010-12-11 00:31:29 +0000
94+++ ubuntuone/syncdaemon/sync.py 2011-01-04 13:31:28 +0000
95@@ -200,16 +200,6 @@
96 """Move file to conflict."""
97 self.fs.move_to_conflict(self.get_mdid())
98
99- def refresh_stat(self):
100- """Refresh the stat."""
101- path = self["path"]
102- # pylint: disable-msg=W0704
103- try:
104- self.fs.refresh_stat(path)
105- except OSError:
106- # no file to stat, nothing to do
107- pass
108-
109 def safe_get(self, key, default='^_^'):
110 """Safe version of self.get, to be used in the FileLogger."""
111 # catch all errors as we are here to help logging

Subscribers

People subscribed via source and target branches