Merge lp:~mmcg069/software-center/bug839462 into lp:software-center

Proposed by Michael Vogt
Status: Rejected
Rejected by: Michael Vogt
Proposed branch: lp:~mmcg069/software-center/bug839462
Merge into: lp:software-center
Diff against target: 120 lines (+35/-7) (has conflicts)
3 files modified
softwarecenter/ui/gtk3/views/appdetailsview_gtk.py (+1/-1)
softwarecenter/ui/gtk3/widgets/thumbnail.py (+1/-0)
softwarecenter/utils.py (+33/-6)
Text conflict in softwarecenter/utils.py
To merge this branch: bzr merge lp:~mmcg069/software-center/bug839462
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+75317@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for your branch.

This is indeed a way of fixing the race condition. I used a slightly different approach
in http://bazaar.launchpad.net/~software-store-developers/software-center/trunk/revision/2325

It uses the same idea but a more GIOish approach. Please have a look and let me know if you
think this is sufficient or if it misses anything that your branch is doing.

Thanks!
 Michael

Revision history for this message
Michael Vogt (mvo) wrote :

If sufficient it would be nice if you could mark the branch superseeded so that it does not show up in the code browser.

Revision history for this message
Matthew McGowan (mmcg069) wrote :

looks good, will mark my branch superseded.

Cheers
Matt

On Wed, Sep 14, 2011 at 9:34 PM, Michael Vogt <email address hidden>wrote:

> If sufficient it would be nice if you could mark the branch superseeded so
> that it does not show up in the code browser.
> --
> https://code.launchpad.net/~mmcg069/software-center/bug839462/+merge/75317
> You are the owner of lp:~mmcg069/software-center/bug839462.
>

--
From the mind of me!

Unmerged revisions

2154. By Matthew McGowan

make the log messages more informational

2153. By Matthew McGowan

fix another small programming error

2152. By Matthew McGowan

using loggin and shuffle timestamp_mismatch check around

2151. By Matthew McGowan

fix a wee programmign error

2150. By Matthew McGowan

with regards thumbnail downloading enforce timestamp matching to ensure the correct image gets displayed in scenarios where there is an existing thumbnail is being downloaded when an itemview page gets configured to a new pkg/app.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview_gtk.py'
2--- softwarecenter/ui/gtk3/views/appdetailsview_gtk.py 2011-09-11 11:25:44 +0000
3+++ softwarecenter/ui/gtk3/views/appdetailsview_gtk.py 2011-09-14 09:31:17 +0000
4@@ -1588,7 +1588,7 @@
5 elif app_details.icon_url:
6 LOG.debug("did not find the icon locally, must download it")
7
8- def on_image_download_complete(downloader, image_file_path):
9+ def on_image_download_complete(downloader, image_file_path, *args):
10 # when the download is complete, replace the icon in the view with the downloaded one
11 try:
12 pb = GdkPixbuf.Pixbuf.new_from_file(image_file_path)
13
14=== modified file 'softwarecenter/ui/gtk3/widgets/thumbnail.py'
15--- softwarecenter/ui/gtk3/widgets/thumbnail.py 2011-09-12 02:49:29 +0000
16+++ softwarecenter/ui/gtk3/widgets/thumbnail.py 2011-09-14 09:31:17 +0000
17@@ -91,6 +91,7 @@
18
19 # convienience class for handling the downloading (or not) of any screenshot
20 self.loader = SimpleFileDownloader()
21+ self.loader.enforce_timestamp_matching = True
22 self.loader.connect('error', self._on_screenshot_load_error)
23 self.loader.connect('file-url-reachable', self._on_screenshot_query_complete)
24 self.loader.connect('file-download-complete', self._on_screenshot_download_complete)
25
26=== modified file 'softwarecenter/utils.py'
27--- softwarecenter/utils.py 2011-09-14 09:30:28 +0000
28+++ softwarecenter/utils.py 2011-09-14 09:31:17 +0000
29@@ -523,7 +523,15 @@
30 def __init__(self):
31 GObject.GObject.__init__(self)
32 self.tmpdir = None
33+<<<<<<< TREE
34 self._cancellable = None
35+=======
36+ self.enforce_timestamp_matching = False
37+
38+ def _timestamp_mismatch(self, timestamp):
39+ return (self.enforce_timestamp_matching and
40+ timestamp != self.timestamp)
41+>>>>>>> MERGE-SOURCE
42
43 def download_file(self, url, dest_file_path=None, use_cache=False,
44 simple_quoting_for_webkit=False):
45@@ -538,6 +546,7 @@
46 """
47 self.LOG.debug("download_file: %s %s %s" % (
48 url, dest_file_path, use_cache))
49+ self.url = url
50
51 # cancel anything pending to avoid race conditions
52 # like bug #839462
53@@ -568,8 +577,8 @@
54 self.tmpdir = tempfile.mkdtemp(prefix="software-center-")
55 dest_file_path = os.path.join(self.tmpdir, uri_to_filename(url))
56
57- self.url = url
58 self.dest_file_path = dest_file_path
59+ self.timestamp = GObject.get_current_time()
60
61 # FIXME: we actually need to do etag based checking here to see
62 # if the source needs refreshing
63@@ -584,15 +593,23 @@
64 f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_SIZE, 0, 0,
65 self._cancellable,
66 self._check_url_reachable_and_then_download_cb,
67- None)
68+ (self.timestamp,))
69 else:
70 f = Gio.File(url)
71 # first check if the url is reachable
72 f.query_info_async(Gio.FILE_ATTRIBUTE_STANDARD_SIZE,
73- self._check_url_reachable_and_then_download_cb)
74-
75+ self._check_url_reachable_and_then_download_cb,
76+ (self.timestamp,))
77+ return
78+
79 def _check_url_reachable_and_then_download_cb(self, f, result, user_data=None):
80 self.LOG.debug("_check_url_reachable_and_then_download_cb: %s" % f)
81+
82+ timestamp = user_data[0]
83+ if self._timestamp_mismatch(timestamp):
84+ self.LOG.debug("timestamp mismatch. discarding result - this:%s != current:%s" % (timestamp, self.timestamp))
85+ return
86+
87 try:
88 info = f.query_info_finish(result)
89 etag = info.get_etag()
90@@ -602,18 +619,28 @@
91 etag))
92 # url is reachable, now download the file
93 if have_gi:
94+<<<<<<< TREE
95 f.load_contents_async(
96 self._cancellable, self._file_download_complete_cb, None)
97+=======
98+ f.load_contents_async(None, self._file_download_complete_cb, (timestamp,))
99+>>>>>>> MERGE-SOURCE
100 else:
101- f.load_contents_async(self._file_download_complete_cb)
102+ f.load_contents_async(self._file_download_complete_cb, (timestamp,))
103 except GObject.GError as e:
104 self.LOG.debug("file *not* reachable %s" % self.url)
105 self.emit('file-url-reachable', False)
106 self.emit('error', GObject.GError, e)
107 del f
108
109- def _file_download_complete_cb(self, f, result, path=None):
110+ def _file_download_complete_cb(self, f, result, user_data=None):
111 self.LOG.debug("file download completed %s" % self.dest_file_path)
112+
113+ timestamp = user_data[0]
114+ if self._timestamp_mismatch(timestamp):
115+ self.LOG.debug("timestamp mismatch. discarding result - this:%s != current:%s" % (timestamp, self.timestamp))
116+ return
117+
118 # The result from the download is actually a tuple with three
119 # elements (content, size, etag?)
120 # The first element is the actual content so let's grab that