diff --git a/openerp/addons/base/ir/ir_attachment.py b/openerp/addons/base/ir/ir_attachment.py index 2dffe9d0b86..73a8867a98d 100644 --- a/openerp/addons/base/ir/ir_attachment.py +++ b/openerp/addons/base/ir/ir_attachment.py @@ -255,9 +255,8 @@ class ir_attachment(osv.osv): """ compute the checksum for the given datas :param bin_data : datas in its binary form """ - if bin_data: - return hashlib.sha1(bin_data).hexdigest() - return False + # an empty file has a checksum too (for caching) + return hashlib.sha1(bin_data or '').hexdigest() def _compute_mimetype(self, values): """ compute the mimetype of the given values diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index cc2e01890b2..48479528bd0 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -107,6 +107,7 @@ class ir_http(osv.AbstractModel): wdate = attach[0]['__last_update'] datas = attach[0]['datas'] or '' name = attach[0]['name'] + checksum = attach[0]['checksum'] or hashlib.sha1(datas).hexdigest() if (not datas and name != request.httprequest.path and name.startswith(('http://', 'https://', '/'))): @@ -120,7 +121,7 @@ class ir_http(osv.AbstractModel): # just in case we have a timestamp without microseconds response.last_modified = datetime.datetime.strptime(wdate, server_format) - response.set_etag(attach[0]['checksum']) + response.set_etag(checksum) response.make_conditional(request.httprequest) if response.status_code == 304: