Skip to content

Commit

Permalink
Don't crash if home directory isn't writable.
Browse files Browse the repository at this point in the history
Most of our CookieJar.save() calls were wrapped in a try/except to catch
IOErrors, but the one in http_put wasn't. This meant if the home directory
wasn't writable (for example, in some automated post-commit scenarios),
post-review would crash with an uncaught exception. Trivial fix.

Fixes bug 2344.
  • Loading branch information
davidt committed Feb 12, 2012
1 parent 6d524dd commit 1356362
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rbtools/postreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,10 @@ def http_put(self, path, fields):
try:
r = HTTPRequest(url, body, headers, method='PUT')
data = urllib2.urlopen(r).read()
self.cookie_jar.save(self.cookie_file)
try:
self.cookie_jar.save(self.cookie_file)
except IOError, e:
debug('Failed to write cookie file: %s' % e)
return data
except urllib2.HTTPError, e:
# Re-raise so callers can interpret it.
Expand All @@ -821,7 +824,10 @@ def http_delete(self, path):
try:
r = HTTPRequest(url, method='DELETE')
data = urllib2.urlopen(r).read()
self.cookie_jar.save(self.cookie_file)
try:
self.cookie_jar.save(self.cookie_file)
except IOError, e:
debug('Failed to write cookie file: %s' % e)
return data
except urllib2.HTTPError, e:
# Re-raise so callers can interpret it.
Expand Down

0 comments on commit 1356362

Please sign in to comment.