From a171da0ef3e1c9b93034e57cfda4b0f567e00ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 23 Mar 2010 10:54:27 +0100 Subject: [PATCH] Catch exception from os.stat in attachment An OSError exception can occurs if the file is no more there or if the data_path is wrong. --- trytond/ir/attachment.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/trytond/ir/attachment.py b/trytond/ir/attachment.py index 5a3680673d..1072388172 100644 --- a/trytond/ir/attachment.py +++ b/trytond/ir/attachment.py @@ -51,8 +51,11 @@ class Attachment(ModelSQL, ModelView): filename = os.path.join(CONFIG['data_path'], db_name, filename[0:2], filename[2:4], filename) if name == 'datas_size': - statinfo = os.stat(filename) - value = statinfo.st_size + try: + statinfo = os.stat(filename) + value = statinfo.st_size + except OSError: + pass else: try: file_p = open(filename, 'rb')