Merge lp:~mandel/ubuntuone-client/donot-add-watches-parents into lp:ubuntuone-client

Proposed by Manuel de la Peña
Status: Rejected
Rejected by: Manuel de la Peña
Proposed branch: lp:~mandel/ubuntuone-client/donot-add-watches-parents
Merge into: lp:ubuntuone-client
Diff against target: 110 lines (+48/-4)
4 files modified
tests/syncdaemon/test_localrescan.py (+20/-1)
ubuntuone/platform/__init__.py (+1/-0)
ubuntuone/platform/local_rescan.py (+25/-0)
ubuntuone/syncdaemon/local_rescan.py (+2/-3)
To merge this branch: bzr merge lp:~mandel/ubuntuone-client/donot-add-watches-parents
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Disapprove
Natalia Bidart (community) Needs Fixing
Diego Sarmentero (community) Approve
Review via email: mp+73648@code.launchpad.net

Commit message

Fixes Lp:838111

Adds a platform dependent flag that lets synd-daemon know if the parents of the UDF should be watched or not according to the platform.

Description of the change

Fixes Lp:838111

Adds a platform dependent flag that lets synd-daemon know if the parents of the UDF should be watched or not according to the platform.

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

We will not be adding a new module to define constant.

We talked with Manuel and Facundo about this, and we're using the __init__.py modules in platform to do this.

review: Needs Fixing
Revision history for this message
Manuel de la Peña (mandel) wrote :

After mumble conversations this branch is rejected so that a nicer and more secure internal API is used.

review: Disapprove

Unmerged revisions

1123. By Manuel de la Peña

Link bug.

1122. By Manuel de la Peña

Added a flag that is created per platform that decides if wathces should be added to the parent of a UDF.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_localrescan.py'
2--- tests/syncdaemon/test_localrescan.py 2011-08-30 18:04:23 +0000
3+++ tests/syncdaemon/test_localrescan.py 2011-09-01 10:32:23 +0000
4@@ -2260,7 +2260,8 @@
5 self._logger = logging.getLogger('ubuntuone.SyncDaemon')
6 self._logger.addHandler(self.handler)
7 self.addCleanup(self._logger.removeHandler, self.handler)
8-
9+
10+ @skipIfOS('win32', 'This is a linux specific test.')
11 @defer.inlineCallbacks
12 def test_ancestors_have_watch(self):
13 """UDF's ancestors have a watch."""
14@@ -2277,6 +2278,24 @@
15 self.assertTrue(self.handler.check_debug("Adding watch to UDF's",
16 repr(self.ancestors[0])))
17
18+ @skipIfOS('linux2', 'This is a windows specific test.')
19+ @defer.inlineCallbacks
20+ def test_ancestors_do_not_have_watch(self):
21+ """UDF's ancestors have a watch."""
22+ yield self.lr.start()
23+
24+ expected = set(self.ancestors)
25+ actual = set(self.watches)
26+ difference = expected.symmetric_difference(actual)
27+ msg = 'Expected (%s)\n\n' \
28+ 'Is subset of real watches (%s).\n\n' \
29+ 'Set symmetric difference is: %s.' % \
30+ (expected, actual, difference)
31+ self.assertFalse(expected.issubset(actual), msg)
32+ self.assertFalse(self.handler.check_debug("Adding watch to UDF's",
33+ repr(self.ancestors[0])))
34+
35+
36 @defer.inlineCallbacks
37 def test_watch_is_not_added_if_present(self):
38 """Watches are not added if present."""
39
40=== modified file 'ubuntuone/platform/__init__.py'
41--- ubuntuone/platform/__init__.py 2011-08-16 13:44:20 +0000
42+++ ubuntuone/platform/__init__.py 2011-09-01 10:32:23 +0000
43@@ -10,6 +10,7 @@
44 from ubuntuone.platform import linux
45 source = linux
46
47+from ubuntuone.platform import local_rescan
48 from ubuntuone.platform import credentials
49
50 target = sys.modules[__name__]
51
52=== added file 'ubuntuone/platform/local_rescan.py'
53--- ubuntuone/platform/local_rescan.py 1970-01-01 00:00:00 +0000
54+++ ubuntuone/platform/local_rescan.py 2011-09-01 10:32:23 +0000
55@@ -0,0 +1,25 @@
56+# ubuntuone.platform.local_rescan
57+#
58+# Author: Manuel de la Pena <manuel@canonical.com>
59+#
60+# Copyright 2011 Canonical Ltd.
61+#
62+# This program is free software: you can redistribute it and/or modify it
63+# under the terms of the GNU General Public License version 3, as published
64+# by the Free Software Foundation.
65+#
66+# This program is distributed in the hope that it will be useful, but
67+# WITHOUT ANY WARRANTY; without even the implied warranties of
68+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
69+# PURPOSE. See the GNU General Public License for more details.
70+#
71+# You should have received a copy of the GNU General Public License along
72+# with this program. If not, see <http://www.gnu.org/licenses/>.
73+"""Platform specific local rescan code."""
74+import sys
75+
76+# import the correct code from the package
77+if sys.platform == 'win32':
78+ watch_ancestors = False
79+else:
80+ watch_ancestors = True
81
82=== modified file 'ubuntuone/syncdaemon/local_rescan.py'
83--- ubuntuone/syncdaemon/local_rescan.py 2011-08-22 14:20:30 +0000
84+++ ubuntuone/syncdaemon/local_rescan.py 2011-09-01 10:32:23 +0000
85@@ -38,7 +38,7 @@
86 rename,
87 stat_path,
88 )
89-
90+from ubuntuone.platform.local_rescan import watch_ancestors
91
92 class ScanTransactionDirty(Exception):
93 """The transaction was dirty."""
94@@ -271,7 +271,6 @@
95 m = "Unsubscribing UDF %r because not in disk: %r"
96 log_info(m, volume.volume_id, volume.path)
97 self.vm.unsubscribe_udf(volume.volume_id)
98-
99 for ancestor in volume.ancestors:
100 # check that ancestor is still there
101 if not access(ancestor):
102@@ -311,7 +310,7 @@
103 try:
104 # add watches to UDF ancestors and check UDF is ok
105 volume = scan_info[0]
106- if isinstance(volume, volume_manager.UDF):
107+ if isinstance(volume, volume_manager.UDF) and watch_ancestors:
108 udf_ok = yield self._add_watches_to_udf_ancestors(volume)
109 if not udf_ok:
110 self._process_next_queue(None)

Subscribers

People subscribed via source and target branches