Merge lp:~robru/friends/avatar-expiry-workaround into lp:friends

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 173
Merged at revision: 172
Proposed branch: lp:~robru/friends/avatar-expiry-workaround
Merge into: lp:friends
Diff against target: 84 lines (+16/-7)
3 files modified
debian/changelog (+8/-2)
friends/service/dispatcher.py (+4/-1)
friends/utils/avatar.py (+4/-4)
To merge this branch: bzr merge lp:~robru/friends/avatar-expiry-workaround
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot (community) continuous-integration Approve
Robert Bruce Park Approve
Review via email: mp+155653@code.launchpad.net

Commit message

Stop expiring old avatars from the cache.

Description of the change

So Ken, in light of the fact that we are quite late in the freeze, and the "correct" avatar fix would require new API (and thus a FFe), I propose that we land this workaround, and then early in the S cycle we can worry about fixing this "properly".

This commit simply neuters our ExpireAvatar dbus method (without removing it, so nothing that uses that API needs to be altered), and then it adds a simple mtime check to the download logic, causing it to trigger a redownload even if the file is already in the cache. End result: cached avatars are never deleted, but stale ones are redownloaded monthly.

This way older posts in the stream will not be robbed of their Avatar images.

Next cycle we can look at a) adding new GetCachedAvatar dbus method, b) updating libfriends API, and c) updating gwibber to know that the avatar field no longer contains cached data but raw URLs. (I almost wonder if maybe Qml doesn't provide some kind of caching mechanism that might be a bit more streamlined than having to query DBus for cached downloads...)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:171
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~robru/friends/avatar-expiry-workaround/+merge/155653/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/friends-ci/12/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/friends-raring-amd64-ci/12

Click here to trigger a rebuild:
http://s-jenkins:8080/job/friends-ci/12/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, but needs a debian/changelog entry

review: Needs Fixing
172. By Robert Bruce Park

* Don't delete stale avatars, just redownload periodically (LP: #1153896)

Revision history for this message
Robert Bruce Park (robru) wrote :

Oops, ok. Please merge ;-)

review: Approve
173. By Robert Bruce Park

[ Robert Bruce Park ]
* Flickr photos are 404ing (LP: #1159979)
[ Ubuntu daily release ]
* Automatic snapshot from revision 170

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:172
http://jenkins.qa.ubuntu.com/job/friends-ci/14/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/friends-raring-amd64-ci/14

Click here to trigger a rebuild:
http://s-jenkins:8080/job/friends-ci/14/rebuild

review: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-03-28 05:01:42 +0000
3+++ debian/changelog 2013-03-29 16:07:23 +0000
4@@ -1,3 +1,9 @@
5+friends (0.1.3daily13.03.29-0ubuntu1) UNRELEASED; urgency=low
6+
7+ * Don't delete stale avatars, just redownload periodically (LP: #1153896)
8+
9+ -- Robert Bruce Park <robert.park@canonical.com> Fri, 29 Mar 2013 08:58:45 -0700
10+
11 friends (0.1.3daily13.03.28-0ubuntu1) raring; urgency=low
12
13 [ Robert Bruce Park ]
14@@ -29,13 +35,13 @@
15 [ Robert Bruce Park ]
16 * Keep the Dispatcher alive for 30s beyond the return of the final
17 method invocation.
18- * Stop deduplicating messages across protocols, simplifying model
19+ * Stop deduplicating messages across protocols, simplifying model
20 schema (LP: #1156941)
21 * Add schema columns for latitude, longitude, and location name.
22 * Fix 'likes' column from gdouble to guint64.
23 * Add geotagging support from foursquare, facebook, flickr.
24 * Implement since= for Facebook, reducing bandwidth usage.
25- * Automatically prepend the required @mention to Twitter
26+ * Automatically prepend the required @mention to Twitter
27 replies (LP: #1156829)
28 * Automatically linkify URLs that get published to the model.
29 * Fix the publishing of Facebook Stories (LP: #1155785)
30
31=== modified file 'friends/service/dispatcher.py'
32--- friends/service/dispatcher.py 2013-03-20 01:19:39 +0000
33+++ friends/service/dispatcher.py 2013-03-29 16:07:23 +0000
34@@ -358,4 +358,7 @@
35 @exit_after_idle
36 @dbus.service.method(DBUS_INTERFACE)
37 def ExpireAvatars(self):
38- Avatar.expire_old_avatars()
39+ pass
40+ # Disabled because we don't currently have a way of re-fetching
41+ # expired avatars if they're needed again later.
42+ # Avatar.expire_old_avatars()
43
44=== modified file 'friends/utils/avatar.py'
45--- friends/utils/avatar.py 2013-02-27 16:52:19 +0000
46+++ friends/utils/avatar.py 2013-03-29 16:07:23 +0000
47@@ -33,7 +33,7 @@
48
49 CACHE_DIR = os.path.realpath(os.path.join(
50 GLib.get_user_cache_dir(), 'friends', 'avatars'))
51-CACHE_AGE = timedelta(weeks=4)
52+AGE_LIMIT = date.today() - timedelta(weeks=4)
53
54
55 try:
56@@ -60,13 +60,14 @@
57 local_path = Avatar.get_path(url)
58 try:
59 size = os.stat(local_path).st_size
60+ mtime = date.fromtimestamp(os.stat(local_path).st_mtime)
61 except OSError as error:
62 if error.errno != errno.ENOENT:
63 # Some other error occurred, so propagate it up.
64 raise
65 # Treat a missing file as zero length.
66 size = 0
67- if size == 0:
68+ if size == 0 or mtime < AGE_LIMIT:
69 log.debug('Getting: {}'.format(url))
70 image_data = Downloader(url).get_bytes()
71
72@@ -89,11 +90,10 @@
73 def expire_old_avatars():
74 """Evict old files from the cache."""
75 log.debug('Checking if anything needs to expire.')
76- limit = date.today() - CACHE_AGE
77 for filename in os.listdir(CACHE_DIR):
78 path = os.path.join(CACHE_DIR, filename)
79 mtime = date.fromtimestamp(os.stat(path).st_mtime)
80- if mtime < limit:
81+ if mtime < AGE_LIMIT:
82 # The file's last modification time is earlier than the oldest
83 # time we'll allow in the cache. However, due to race
84 # conditions, ignore it if the file has already been removed.

Subscribers

People subscribed via source and target branches